I created a project using qmake and it automatically generated moc files for classes that inherit QObject either directly or indirectly. However, if I add a new class that inherits the QObject the QT plugin doesn't generate MOC files during the build process. What settings should I tweak so that I can do this automatically each time I add a new QObject file?
相关问题
- Sorting 3 numbers without branching [closed]
- QML: Cannot read property 'xxx' of undefin
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- How to show location of errors, references to memb
- Class layout in C++: Why are members sometimes ord
- Log4Net Multiple Projects
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
If your custom classes are not moc'ed automatically, you could have forgotten to add a Q_OBJECT macro in class declarations or to put QObject as the first class that is inherited from in case of multiple inheritance (the order of classes from which your derived class inherits matters). If it's not your case, you may want to read this:
http://truth2.wordpress.com/2010/09/04/custom-build-rules-for-qt-under-visual-studio-2010/
BTW: QT versions have their nuances and thus it is helpful if you inform about which version you use.
I just find a new way of dealing with the "no moc_*.cpp file generated after adding new .h/.cpp file" error.
First, you go to "Solution Explorer -> Right click property page of the new .h file", then change the build to to "Custom Build Tool".
Then, you should find a .h file which has successfully generated "moc_*", and copy all the contents in "Custom Build Tool -> General" to the new .h file setting page.
After that, build your project.
Finally, add the generated "moc_*" file to your project.
Done! Now you can build it as usual.