[Interest] Qt namespaces and Q_MOC_RUN trick (aka: the mistery of qnamespace.h)

Sandro Andrade sandroandrade at kde.org
Thu Jan 10 18:21:31 CET 2013


Hi there,

I need to have some enums defined in a namespace like the ones we can
find at qtbase:src/corelib/global/qnamespace.h.

I've tried the same approach in my project but moc complains with the following:
"Class contains Q_OBJECT macro but does not inherit from QObject"

I know we can use Q_GADGET instead of Q_OBJECT but I'm still getting
some build errors.

The real point is: is there some 'magic' qmake flag or something else
used in qnamespace.h for having
that working properly ?

Sorry if that was discussed before but I found a unique thread at Qt
Centre [1] with no answer to the mistery,
just a 'stick with Q_GADGET' option :(

Thanks,
--
Sandro

[1] http://www.qtcentre.org/archive/index.php/t-19700.html



More information about the Interest mailing list