Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding the location of ui_mainwindow.h in the Qt Creater widgets template

Tags:

qt

qt-creator

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"?

like image 413
Karnivaurus Avatar asked Sep 30 '22 13:09

Karnivaurus


1 Answers

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.

like image 56
ratchet freak Avatar answered Oct 06 '22 18:10

ratchet freak