In my project I need to create QObject derived classes (with Q_OBJECT and signals) using a macro. The macro resides in a separate file. Here is a simplified example:
The macro is declared in the file CreateQtClass.h:
I use the macro to create my class in the file MyQtClass.h
In my .qbs file, I add MyQtClass.h to the files property, like this:
The file main.cpp:
qbs doesn't run 'moc' on MyQtClass.h. It looks like it doesn't do the scanning correctly, and doesn't detect the Q_OBJECT inside the macro.
I have created a simple Makefile to shows that when manually forcing moc to run on MyQtClass.h, everything works well. This is the Makefile:
I think that the problem is that qbs and moc do not scan the files in the same manner. Qbs tries to detect whether the file MyQtClass.h needs to be moc'ed but fails where moc itself succeeds.
The lack of consistency between the two tools (qbs, moc) can lead to situations where files are not detected correctly.
For this reason I think that we need some kind of way to manually tell Qbs that a file (MyQtClass.h, in my case) needs to be moc'ed.
What I suggest is that we add new a fileTag such as "force_moc" which we can attached to files such as MyQtClass.h and force qbs to run moc on them.
Attached all the files to reproduce the problem + the Makefile
|For Gerrit Dashboard: QBS-1410|
|246238,2||Qt: Allow users to explicitly tag files as mocable||master||qbs/qbs||Status: MERGED||+2||0|