Purpose of Q_SLOTS, Q_SIGNALS, Q_EMIT, ...
-
Hi,
can some explain me the purpose of the Q_SLOTS, Q_SIGNALS, Q_DECL_OVERRIDE and Q_EMIT macros.
I also can use slots, signals, override and emit to get the same result.Do the macros have some advantages?
Thanks!
@beecksche
using the "keywords" slots, signals, override and emit may conflict with third party libraries (for example boost::signals) - in this case you can useCONFIG+=no_keywords
and use the macros instead of the mentioned keywords. -
@micland is correct but it's missing
Q_DECL_OVERRIDE
that is just a trick to make it backward compatible. if you useoverride
(which is not a Qt keyword but pure C++) on a compiler that does not support C++11 then it will not compile.Q_DECL_OVERRIDE
is defined asoverride
if the compiler supports it otherwise it translate to nothing at all -
Hi,
can some explain me the purpose of the Q_SLOTS, Q_SIGNALS, Q_DECL_OVERRIDE and Q_EMIT macros.
I also can use slots, signals, override and emit to get the same result.Do the macros have some advantages?
Thanks!
@beecksche said in Purpose of Q_SLOTS, Q_SIGNALS, Q_EMIT, ...:
I also can use slots, signals, override and emit to get the same result.
actually these keywords are also macros mapped to the stated macros of yours. They are just nicer to read.
As @micland already stated, in case they conflict with other libraries you must use the macros. But it doesn't make any difference, since at the end they are mapped to the same macros an interpreted by moc.