Qt GUI doesnt change after compilation

僤鯓⒐⒋嵵緔 提交于 2019-12-06 23:24:09

问题


I created a GUI using the Qt Designer compiled and run.
Then I made a few changes in the GUI and recompiled again but the GUI remained the same.
Even if I delete the widgets and recompile they appear...

I tried Clean All and Clean Project but no success...
What might be the problem?


回答1:


You can recompile your UI with the following command. It worked for me.

uic mainwindow.ui>ui_mainwindow.h



回答2:


I know this is an old thread, but I guess it is still active. One reason for this buggy behavior is the Shadow build checkbox is enabled. Click on the "Project" icon in the Qt creator, under Build-> General, uncheck Shadow build. Rebuild again.




回答3:


I think this is a summary of what should happen.

  • 1. start with an empty project.
  • 2. use QT designer to create a mainwindow.ui file.
  • 3. qt creator is supposed to create for you a header file ui_mainwindow.h containing the necessary definitions for your user interface plus a member function setupUi(). QT creator generates this ui_mainwindow.h file by calling uic(user interface compiler).
  • 4.Now that you have this file, add this code to your project and i think it will display your Qt GUI properly
  • you are free to edit your GUI in Qt designer and recompile to show updated changes(i think) :)
  • #include "ui_mainwindow.h"
    #include <QMainWindow.h>
    #include <QApplication.h>
    
    int main(int argumentCount, char * argumentValues[])
    {
        QApplication app(argumentCount, argumentValues);
        Ui::MainWindow ui;
        QMainWindow * myMainWindow= new QMainWindow();
        ui.setupUi(myMainWindow);
        myMainWindow->show();
        return app.exec();
    }
    

    ps: The class Ui::MainWindow contains a member function setupUi() that setsup for you the GUI.
    Make sure that you have the exact class name because c++ is case sensitive. Good luck.




    回答4:


    You should clean your source directory. Probably you have two ui_mainwindow.h files in different directories. One file from your build by command line, other one frome your build by Qt Creator. It happened with me, and after cleanup everything works well.



    来源:https://stackoverflow.com/questions/4616932/qt-gui-doesnt-change-after-compilation

    易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
    该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!