I am writing my first application with Qt Creator, and I have loaded the default widget template. In mainwindow.cpp
, there is the line #include "ui_mainwindow.h"
. However, this file does not exist yet. After compiling the code, I notice that there is a filed named ui_mainwindow.h
in the build folder.
Please could somebody explain what is going on here? It seems that perhaps there is a two-stage build process, one to build the user interface files (i.e. ui_mainwindow.h
), and then one to build the actual program. In that case, and if this header file is put in the build directory, why is it #include "ui_mainwindow.h"
rather than #include "../build/ui_mainwindow.h"
?
It what the ui builder creates after "uic.exe" parsed your .ui
form-file (where you dragged and dropped the widgets in your main window). There are other tools that pre parses the header files to create the moc_*.cpp
files that holds the functionality for the signals and slots.
It can use #include "ui_mainwindow.h"
because during compilation the build tool adds the build folder to the include directories. And the build directory may change for example you select another build folder for the release build.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With