Possible Duplicate:
Is it possible to see definition of Q_SIGNALS, Q_SLOT, SLOT(), SIGNAL() macros? (Qt)
I couldn't find on Google, the declaration of the macros, SIGNAL and SLOT, in Qt.
When we say, connect(button1, SIGNAL(clicked()), this, SLOT(slotButton1()));
I would like to understand, which all kinds of parameters does the highlighted macros accept?
Any link to doc would be appreciated.
The link I got through Neil's comment below says: #define SLOT(a) "1"#a
and what does a represent here? It is not shown in that link.
As Neil said, the SLOT and SIGNAL macros are defined as
#define SLOT(a) "1"#a
#define SIGNAL(a) "2"#a
The #a (with # a stringizing operator) will simply turn whatever is put within the parentheses into a string literal, to create names from the signatures provided to the macros. The "1" and "2" are merely there to distinguish between slots and signals.
This earlier post should provide you some more insight.
If you wonder about the "why?" of all this macro stuff and preprocessing, I would suggest you read up on the "Meta-Object-Compiler" or MOC. And just for fun you could have a look at what MOC does to the code you provide it with. Look through its output and see what it contains. That should be quite informative.
In short, this preprocessing through MOC allows Qt to implement some features (like the signals and slots) which C++ does not provide as standard. (Although there are arguably some implementations of this concept, not related to Qt, which don't require a Meta Object Compiler)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With