What is the differnce between Signal and slot?
-
Hi all,
I have a doubt about signal and slot.Whether the signal has definition or declaration only.and what is slot?.Please suggest me soon.Thanks
-
-
Hi,
I referred the link mentioned previously.I am clear now with the concept like "Whether signal has implementation?".But still now confused with the signal.
code snippet is
signals:
void ItemAdded( Item item);My question is
1.How this signal is emitted?
2.Why signal has the argument?
3.What is the relation between signal and its parameter? -
Hi,
- how explained in the article, a signal is emitted using the
emit
keyword or theQ_EMIT
macro
emit <signal_name>(<parameters_list>); Q_EMIT <signal_name>(<parameters_list>);
-
Sometimes you need to signal what is changed and not only that something is changed
-
the signal is the notification that something happened, parameters are details about the event
- how explained in the article, a signal is emitted using the
-
Signals are declaration only. Slots provide the code that shall be executed when the signal gets emitted.
When you emit a signal, then all assigned slots are executed with the arguments of the signal.
-
@s.frings74 said:
Signals are declaration only.
Even though other part of explanation is correct above is wrong.
There is no magic and signal is actually a function.
User does not provide its implementation though.
It is automatically generated during mocing.
You can check look at generated code in the generated moc_*.cpp file. -
@mcosta
Thanks.....