Hi, I have seen this line at the end of a main.cpp. What does this do? Thanks
Code:
//main.cpp ......... #include "main.moc"
Printable View
Hi, I have seen this line at the end of a main.cpp. What does this do? Thanks
Code:
//main.cpp ......... #include "main.moc"
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
You put class definitions in .cpp file only when you don't want them to be visible outside that file.Quote:
Originally Posted by mickey
but Is there a pratical reason to hide a class into a .cpp? Why to hide?
Thanks
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".Quote:
Originally Posted by mickey
Or when you are lazy and don't want to create three files instead of one. :cool: