If you want a private class that is local to a file, then create a private header file only included by that source file. For example, myfile_internal.h and define your classes there.
If you want a private class that is local to a file, then create a private header file only included by that source file. For example, myfile_internal.h and define your classes there.
doberkofler (2nd March 2010)
There is a better way. If your implementation file that contains a local class is called xyz.cpp then write this under the class declaration:
This instructs qmake to force running moc on xyz.cpp. Remember to rerun qmake after you add this statement.
Qt Code:
Q_OBJECT public: // ... }; #include "myfile.moc"To copy to clipboard, switch view to plain text mode
I'm not sure if I understand you correctly. Does the include xyz.moc have to to exist and what should it contain?
I believe the only reason it is there is that when the makefile is rebuilt it will automatically create a rule to parse the cpp file using MOC, as qmake will parse cpp files for #include lines for dependancy purposes.
Some people also state that doing so can reduce compilation time: http://edu.kde.org/development/tips....emyfilemoccode
There some discussion about it on the Qt interest archive: http://lists.trolltech.com/qt-intere...ad00793-0.html
And it seems to be used more in KDE: http://www.kdevelop.org/3.0/doc/tutorial_settings/#p1
For me it's just a matter of convinience that I don't have to create separate header files just to declare local classes.
Bookmarks