C

Signal Struct

struct Qul::Signal

Allows creating a signal that can be connected from QML. More...

Header: #include <Signal>

Public Functions

void operator()() const

Detailed Description

When you put a signal as a member of a class that derives from Qul::Object or QUl::Singleton, the qmlinterfacegenerator tool will generate a signal that can be connected from the QML code using the onXxxx:{...} syntax.

The template argument of the Signal shall be a function signature, including the parameters names which are used by qmlinterfacegenerator to expose them to qml.

Example:

class MySingleton : public Qul::Singleton<MySingleton> {
public:
    Qul::Signal<void()> changed; // signal without arguments
    Qul::Signal<void(int key, qreal value)> newValue; // signal with arguments
};

This can be used from QML like so:

MySingleton.onNewValue: console.log("Got a new value for key", key, ": ", value);

In order to emit the signal from the C++ code, you can use the operator().

MySingleton::instance().newValue(1, 3.141592);

Member Function Documentation

void Signal::operator()() const

Emit the signal.

Note that this call operator will have arguments if the template argument T has argument.

Available under certain Qt licenses.
Find out more.