[ fromfile: signals.xml id: signals ]
A signal
is a message presented in a class definition like a void
function declaration.
It has a parameter list but no function body.
A signal is part of the interface of a class.
It looks like a function, but it is not invoked the same way – it is emitted by an object of that class.
A slot
is usually a void
member function.
It can be called as a normal member function
it can be invoked indirectly by the QMetaObject system.
A signal
of one object can be connect
ed to the slot
s of one or more objects, provided the objects exist and the parameter lists are compatible from the signal
to the slot
.[41]
The syntax of the connect
statement is
bool QObject::connect(senderQObjectPtr, SIGNAL(signalName(argumentList)), receiverQObjectPointer, SLOT[42](slotName(argumentList)) optionalConnectionType);
Any QObject that has a signal can emit
that signal.
This produces indirect calls to all connected slots.
Arguments passed in the emit
statement are accessible as parameters in the slot function, similar to a direct function call.
The optionalConnectionType
enables you to specify if you want synchronous (blocking) or asynchronous (queued) calls to the destination slots from the emit
point. [43]
Tip | |
---|---|
If you have multiple signals connected to the same slot, and need to know which QObject emitted the signal, you can call |
[41] When the lists are assignment compatible, this means that corresponding parameters must be compatible. In Qt, the slot must have at least as many paramaters as the signal. The slot can ignore extra arguments.
[42] or signal
[43] Connection is not restricted to the current thread Section 17.2
Generated: 2012-03-02 | © 2012 Alan Ezust and Paul Ezust. |