Force Moc to moc a file
-
Hi,
... yes, that was my original question.
Quote from Post:
So my question is, is there any way to tell the moc ( p.e. by means of a define ) to moc the file, although it thinks it shouldn't ?Of course I can put some Q_OBJECT somewhere on the top of the file, p.e.:
#ifdef SOMETHING_WHICH_DEFINITELY_IS_NOT_DEFINED_ELSEWHERE Q_OBJECT #endifwhere it's just there, but not evaluated.
But this looks pretty hacky and not nice.I rather would like something like;
#define Q_FORCE_MOC -
Hi,
Out of curiosity, which version of Qt are we talking about ?
-
Ok,
I understand, that
qmakedoes not recognize ( and probably even cannot - as it supposed doesn't expand macros) that the concerning file needs to get mocced.
Is there any ways then to add something in the pro file to tellqmake, that the file needs to get mocced ? p.e.:moc += bar.h -
qmake is a project manager so indeed it doesn't include macro expansion. moc on the other end (since Qt 5) should expand macro properly.
I just tested your code on OS X and it worked
-
Hi SGaist,
thanx for caring about this issue,
Did yout test it without the Q_OBJECT pseudo code commented or uncommented ?In the meanwhile I started to redesign this part of our software (we are talking about 70-80 type definitions in about 7-8 namespaces resp. files ) - but anyway it would be quite interesting ( at least for me ) to know, if such kind of constructs make sense in the Qt world or not.
-
I've removed/re-added it and it still builds. Q_OBJECT is useful when you implement e.g. signals and slots
-
Strange !
Seems, that my qmake implementation is different from yours.
Reproducable it builds if I have the Q_OBJECT uncommented, and it gives me the linker errors if i have it commented.
So this led me to the assumption, that a (uncommented) Q_OBJECT occurance in a header file is the hint for qmake to mark it to be mocced.
-
Which version of qmake are you using ?
-
Are you calling qmake through Qt Creator or on the command line ?
-
Did you re-try with Qt 5.5 ?