Generally when a .cpp or .h use information of other header, then we should include header in that file.But When the headers in pro file is added?
i.e. HEADERS+=.....
Generally when a .cpp or .h use information of other header, then we should include header in that file.But When the headers in pro file is added?
i.e. HEADERS+=.....
Any header file from your project that contains Q_OBJECT or other Qt specific markers for the metaobject compiler (moc) should be listed in HEADERS so that qmake ensures moc is run on them.
Yes, those two "inclusions" server different purposes.
The include in the cpp file is necessary for the compiler to know about the types and functions declared in that header, in order for code in the cpp file to use them
The adding to the HEADERS variable is necessary for Qt's MOC to process the Qt specific things inside the header, e.g. generate code for signal/slots
The two inclusion points are totally unrelated.
Cheers,
_
Bookmarks