Hi, I have seen this line at the end of a main.cpp. What does this do? Thanks
Qt Code:
//main.cpp ......... #include "main.moc"To copy to clipboard, switch view to plain text mode
Hi, I have seen this line at the end of a main.cpp. What does this do? Thanks
Qt Code:
//main.cpp ......... #include "main.moc"To copy to clipboard, switch view to plain text mode
Regards
It tells qmake to run moc on this file and generate "main.moc" with implementation of the signals and slots mechanism. You must use it when you place class definition with Q_OBJECT macro in a .cpp file.
sorrry, but when do I need to put a class in main.ccp instead of in a apart file? thanks
Regards
You put class definitions in .cpp file only when you don't want them to be visible outside that file.Originally Posted by mickey
but Is there a pratical reason to hide a class into a .cpp? Why to hide?
Thanks
Regards
For example when you are writing a library, you might want to hide the implementation, so that after every change you don't have to recompile all programs that use that library. Ask google about "pimpl" or "d pointer".Originally Posted by mickey
mickey (4th April 2006)
Or when you are lazy and don't want to create three files instead of one.
Bookmarks