When using Qt Creator to develop programs, you must include the # include header file.
As we all know, # include <> is used to include standard library header files. The path is in the include folder where the software is installed; # include "" is used to include custom files, the path is in the current user directory (or in the self-built project directory ).
For the latter, the path is more intuitive and easy to understand. For example, # include "lyc/daniel. h". The path is in the lyc folder of the current directory. (File inclusion can be nested .)
The following describes the path inclusion of the standard library header file of Qt.
1. Create a New GUI project. You can see the # include <QMainWindow> In mainwindow. h file.
2. In the include path of Qt, we can see that there are folders instead of files. Why?
3. Open the pro file in the project to know that the level-2 Directory QtCore and QtGui are already included.
That is, two files in include are added.
4. Search for QMainWindow in the include folder (Note that. h is not included). You can see that QMainWindow is found in the include \ QtGui directory.
5. Open QMainWindow in text. You can see
6. Open the qmainwindow. h file in the QtGui path (the same path as QMainWindow)
As you can see, there is a jump to the path, jump from the current path to the two paths, and then find the qmainwindow. h file in sequence from the src File
7. Open the qmainwindow. h file and you can see
At this point, we can see that the target header file is found.
During compilation, the code in the file will be copied to # include <QMainWindow>.