Problem . When the corresponding .ui file of the QMainWindow or QDialog file has been changed in Qt Designer, the entire project must be cleaned and rebuilt for these changes to take effect: make clean then make . If the project is not cleared first, the changes will not be displayed in the executable file.
Project Structure :
./ project.pro ./include/ MainWindow.h Main.h ./src/ MainWindow.cpp Main.cpp ./ui/ MainWindow.ui
Source :
mainwindow.h:
#include <QMainWindow> #include "ui_MainWindow.h" class MainWindow : public QMainWindow, private Ui::MainWindow { Q_OBJECT public: MainWindow(); };
mainwindow.cpp:
#include "MainWindow.h" MainWindow::MainWindow() { Ui::MainWindow::setupUi(this); }
project.pro:
TEMPLATE = app CONFIG -= debug release CONFIG += qt debug_and_release warn_on incremental flat link_prl embed_manifest_dll embed_manifest_exe QT += xml xmlpatterns INCLUDEPATH += include/ UI_DIR = include/ FORMS += ui/MainWindow.ui HEADERS += include/MainWindow.h include/Main.h SOURCES += src/MainWindow.cpp src/Main.cpp
Note. Include security features and class members for restriction.
Update
Assuming that we edit MainWindow.ui in Designer, save it and run make , the following shell commands are executed (on the Windows platform, equal commands are also executed in the "nix" field):
QTDIR\bin\uic.exe ui\MainWindow.ui -o include\ui_MainWindow.h QTDIR\bin\moc.exe ... include\MainWindow.h -o build\moc\moc_MainWindow.cpp MSVS\bin\cl.exe /c ... -Fobuild\obj\ moc_MainWindow.cpp MSVS\bin\link.exe ... /OUT:bin\target.exe
The uic header generator started and the window was moc'ed. Despite this, the window remains unchanged in the executable file.
Update # 2 :
I found these lines in the Makefile:
####### Compile build\obj\MainWindow.obj: src\MainWindow.cpp build\obj\main.obj: src\main.cpp build\obj\moc_MainWindow.obj: build\moc\moc_MainWindow.cpp
Bingo. MainWindow.obj rightfully depends on MainWindow.cpp , but not on moc_MainWindow.cpp . Changing the first line to build\obj\MainWindow.obj: src\MainWindow.cpp build\moc\moc_MainWindow.cpp all this problem.
However : the next time I run qmake , this will be for me. What can I enter in qmake to fix this forever?