Clarification required in MainWindow Example
With reference to the MainWindow example here : http://qt-project.org/doc/qt-4.8/examples-mainwindow.html
If you look into the mainwindow.h file ( http://qt-project.org/doc/qt-4.8/mainwindows-application-mainwindow-h.html ) , at the top class QAction has been defined , but nowhere could I find any definition of the class.
However, in the mainwindow.cpp file ( http://qt-project.org/doc/qt-4.8/mainwindows-application-mainwindow-cpp.html ) in the createActions method of MainWindow class, an object of QAction is being created by calling its constructor. Howver, I could not find any definition of the constructor.
Since QActios is a library class, shouldn't it be included in the code using '#include' ? Where has QAction class been defined ? What's going on here ?
welcome to devnet
The class statement in this example QAction tells the compiler that QAction is a class. You need this that the compiler knows what to do with the QAction pointer definitions. It does not need more infos at this point.
There is an include for QtGui in the mainwindows. This include basically summarizes a number of other includes (QAction is part of them).
Within the .cpp file the compiler finally needs to know how to handle QAction. This is the latest point to define QAction which is done through the QtGui include.
Here is a link for "some explanation on this (see second code window)":http://www.flipcode.com/archives/Reducing_Dependencies_In_C.shtml