Important: Please read the Qt Code of Conduct -

Modification to form are not reflected when running the application.

  • I am using Qt Creator 4.8 on debian.

    I created a very simple application with a main window with buttons, labels, etc. It has been working fine for some time. Today, I started changing the main window form. I deleted the buttons and labels and added a layout following the examples in Mastering Qt book.

    When I try to reference the new layout from within the code to add a widget, the cpp code says the layout doesn't exist in the ui object. Yet, all of the objects that I deleted are reflected on the ui object.

    I have deleted every reference I could find in the files to the objects. I have cleaned the solution, run qmake and re-compiled. When I run the application, the old form displays as if I hadn't made any changes.

    Any ideas what might be happening? What am I doing wrong?

  • Lifetime Qt Champion


    How did you change that exactly ? Manually or using Designer ?
    Did you check that the code generated from your UI file ?

  • @SGaist I opened the form in the designer, clicked on the objects and pressed the delete button for each of the controls on the form that I wanted to delete. I re-compiled and ran it. The old controls were still there.

    After it wasn't working and I had tried everything else, I looked at the ui_mainwindow.h file and found the references. So, I deleted that file and then ran, "touch ui_mainwindow.h" to create a blank file and hoping it would re-create it when I re-compiled. No luck. I still get the old controls when I run the application from within Qt.

    I could trash it completely and start over. And so, I tried that. I right clicked on mainwindow.ui file and removed it permanently. I then re-created it with the designer with a different set of controls. No luck. Whenever I run the application, it get the old form.

  • Moderators

    @Daniel-Williams said in Modification to form are not reflected when running the application.:

    Any ideas what might be happening?

    My first guess is that there's more than 1 copy of your project on disk, and somewhere along the line the paths got mixed up so you're editing 1 copy but building another.

    1. Have a look inside the Makefile. Do the paths look correct?
    2. Close Qt Creator and delete your *.pro.user file. Re-launch the project. Does that fix things?

  • Qt Champions 2017

    In addition to what @JKSH said, search for ui_mainwindow.h. Some where you have copied this file and Qt creator is finding this file while compiling.

  • Moderators

    @Daniel-Williams did you actually rerun qmake after changing the ui?
    qmake or cmake is needed to create cpp code out of your ui file that than is used to create binary code, if you do not delete/clean your build folder than changes you made in the ui will only be noticebale when you manualy select a qmake rerun.

  • @JKSH Thanks for the suggestions. The Makefile looks good and I deleted the *.pro.user file. FYI, this is a subdirs project with several libraries and a gui project. Qt also installed the most recent 4.8.1 update. I get the same results.

  • Qt Champions 2017

    @Daniel-Williams you must be having ui_mainwindow.h somewhere. Just check by mistake this file is checked in somewhere. Also just go mainwindow.cpp file, on the top of the file you will see entry ui_mainwindow.h. When you click which files does it resolve to ?

  • Clean or delete your build directory, run QMake, then try building again. I have had this happen a few times to me as well.

  • @dheerendra I went to the root of my repo and issues: find . -iname 'ui_mainwindow.h' I found an older gui project I had created as training with the file and I deleted that folder. Other than that, I only have 1 other file with that name.

    Trying to be thorough, I found the name of a control that shouldn't be on the ui object but is (lblRBG1). I did: grep -iR 'lblRBG1' * It returned 0 files which was a surprising to me.

    With all this digging, I'm feeling much more comfortable with how the projects run. I plan on creating a new window with the the layout I want. I'll just switch to using the new window and delete all references to ui_mainwindow. Once I stop looking, I'll probably find the cause next week some time ;) And it's likely operator error :D

    Thanks again for the suggestions.

Log in to reply