Signal Class

(Qul::Signal)
Header: #include <Signal>

Public Functions

void connect(typename List::Node *d)
void operator()()

Detailed Description

The signal class can be used to create a signal that can be connected from QML

When you put a signal as a member of a class that derives from Qul::Object or QUl::Singleton, the qmlinterfaceextractor 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 qmlinterfaceextractor 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, float 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::connect(typename List::Node *d)

void Signal::operator()()

Emit the signal.

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