50

Someone wrote out a GUI in Qt designer earlier and now I have to modify some small parts (i.e. add a button/functionality).

Premise: I add the new feature/make any modification to the .ui file in Designer. I can go to edit mode and see that this makes changes to the xml format of the .ui file

Problem: When I build and run Qt, the old version of the .ui is what is shown (without my feature upgrades). I tried cleaning everything and running qmake, but to no avail.

Any ideas for why this could be happening?

Chris
  • 511
  • 1
  • 4
  • 4

15 Answers15

142

I had the same problem and it was solved when I disabled "Shadow Build" in "Projects" mode.

UPD: Still receiving upvotes for this answer makes me sad for 2 reasons

  • it is trivial
  • the issue is still there after almost 5 years
ironic
  • 8,368
  • 7
  • 35
  • 44
  • 6
    This really deserves more votes! In my opinion, this would be the answer. – PascalVKooten Aug 21 '13 at 15:58
  • 2
    This solved this exact problem for me. The .h files were not being updated from the XML until I unchecked this. – Joshua Sep 08 '13 at 17:01
  • 5
    Just a sidenote: I had to restart QT after I disabled the "Shadow Build" option to make it work. – Natan Streppel Mar 14 '14 at 01:12
  • Luckily I see this after messing with Qt designer for an hour. – Carson Ip Feb 23 '15 at 13:54
  • I tried re-enabling the shadow build, but qt-creator stopped recognizing my changes (such as added gui items). Not sure why that is. @streppel We may be using different OS's, but I didn't have to restart QT after unchecking the Shadow Build box to get it to work. (Gentoo + QT 5.6.1) – NuclearPeon Aug 11 '16 at 07:21
  • I'm new to Qt Quick Designer but it seems to me like this is a bug -- no matter where the build happens it seems like it should pick up any changes you make. Would anyone agree and does anyone know if it's already been opened? There's a similar thread here: http://stackoverflow.com/questions/29341724/qtcreator-build-doesnt-update-ui-changes-in-design-form – rusty Oct 13 '16 at 21:36
  • There's no shadow build option in Qt 5.9. I had to instead delete ui_mainwindow.h file and run `qmake` – Abhishek Agarwal Sep 13 '17 at 05:40
  • Thank you very much, I almost smashed my computer – Nezbeda Feb 11 '18 at 13:42
  • Thanks - just fixed my issue Qt5.11.1 – Willeman Jun 20 '18 at 12:54
  • You saved me! I was so frustrated!! The hell is shadow build anyways – smoothware Oct 13 '18 at 21:24
  • @smoothware Shadow build is to use some other directory than your source directory to store the build results (.moc's, .o's, executables, etc.). This is important to keep your sources clean. – Paulo Carvalho Feb 08 '19 at 14:50
  • There is a third reason for this to make you sad: out-of-source builds are *better* than in-source in almost every case where there is a difference, so anything that forces the use of in-source builds is ***bad***. – dmckee --- ex-moderator kitten Jul 26 '19 at 20:18
  • Fantastic. This also solved my issue of not being able to override the Plasma window style settings configured system-wide in KDE. – Emmanuel Buckshi Dec 24 '19 at 19:41
  • You are a hero:) Solved my issue with Qt 15.5. – Omid Jun 17 '20 at 09:02
16

I could solve this problem wihtout change Shadow Build configuration. In my project I want to build with output files into build-ProjectName-Debug

But the QtCreator is not smart to check if are not files moc_FileName.cpp and ui_FileName.h into build directory. This problem occur because if these files moc_FileName.cpp and ui_FileName.h are into project directory the QtCreator uses them and does not recognize any modification on .ui files.

The solution to this problem was easy to me: Remove all moc_FileName.cpp and ui_FileName.h from project directory and Rebuild. These files will be created into build-ProjectName-Debug and all modifications will be there.

user6284
  • 161
  • 1
  • 4
9

When you change a .ui file, someone needs to run uic.exe on the file to generate a header file. For example, for a window called MyWindow.ui, this will generate a file called ui_MyWindow.h.

This is then what is used when the application is rebuilt.

You don't specify how you are building or on what OS, so it is hard to help you on that end. If you are using Visual Studios it is possible to integrate your .ui files into your projects so that when you change any .ui file, all the generated files will be recreated automatically. The same is possible if you are using .pri files.

In any case, I would run:

uic.exe -o ui_yourfile.h yourfile.ui

Please change the names of the files to the ones you are using. uic.exe can be found in your Qt bin directory.

Then once you have the generated header file, try to find where it goes in the build directory. Then rebuild.

spenibus
  • 4,339
  • 11
  • 26
  • 35
Liz
  • 8,780
  • 2
  • 36
  • 40
6

This is what helped me personally, add to qmake file: UI_DIR = $$PWD

cen
  • 2,873
  • 3
  • 31
  • 56
  • This works better than unchecking the shadow build as a rebuild ensures the moc step is performed on the .ui file. No need to disable shadow build (which seems to break other things). Using Qt 5.15.4. – kashiraja Jun 17 '21 at 07:01
4

I solve this problem by cleanthenbuild.I find that ,if I checked Shadow Build,qtCreator will use the old .obj,other than generate new .obj even if the ui_xxx.h had been changed,to generate .exe when debug agin.My enviroment is qt5.5 + msvc2013.

Crawl.W
  • 403
  • 5
  • 17
2

I had the same problem and was able to solve it by deleting all the Makefiles in the build directory, then rebuilding from scratch. For some reason, these files are not deleted when you run Clean Project from Qt Creator.

ishmael
  • 1,796
  • 3
  • 18
  • 19
1

Same problem for me. Nothing works until I changed the installation from Qt 5.0.2 (MSVC 2010) to Qt 5.0.2 (mingw). Now it is working again...wired

maniax
  • 11
  • 1
1

I experienced the same problem: no ui changes appeared after building. The problem as mentioned above is that the ui files are not getting remade.

Unchecking shadow build solved the problem for me but only once. After that I could not see subsequent ui changes again. So I rechecked shadow build and deleted the existing shadow build folder. This works consistently now, as long as I delete all the build files. But that's lame. It should be able to detect ui changes and remake the files.

I think this should be logged as a bug in Qt Creator/Designer.

AKstat
  • 354
  • 3
  • 14
1

I deleted all auto gen file in source folder. when I unchecked shadow build, auto gen file was created in source folder. after when I checked shadow build, compiler only use source folder's gen file. So I deleted all auto gen file(ui_, moc_) and then ui was updated always.

TAK
  • 11
  • 1
1

In my case, the problem was caused by a rename of the .ui file. Qt Creator didn't update the #include for the header file "ui_[name_of_ui_file].h" in the .cpp file corresponding to the form. Anyway, cleaning up all the "ui_*.h" files in the shadow build folder solved the issue (I guess unchecking "shadow build" in the Project tab would produce the same effect).

1

Have you been playing with the system date or time or they were different from those of your fellow's computer? I was changing the time to some hours later for testing purposes (and compiling the project in the meantime) and after restoring it to current time, the compiled files were not updated because they were newer than the compilation time. Running Clean did not delete those files. Unchecking the Shadow build option only gave me crashes and an untraceable 0xc0000135 error. Deleting manually the moc_*.o and *.cpp files with future date/time from the building directory and compiling the whole project again was the solution for me.

1

Add the following line into .pro file

   UI_DIR = $$PWD
Prayag k
  • 647
  • 9
  • 23
0

As mentioned above, the ui files are not getting recreated. For me, the easiest solution is just hitting Rebuild instead of Build. No need to go into project submenues each time. As long as your project is not too big, this is OK (apart from this is an anoying bug that qt has for long years now)

transistor
  • 649
  • 6
  • 11
  • What if there is no build as it is a Python project, for some reason ui_main.py is not saved with ui_main.ui? – NoBugs Apr 16 '18 at 06:52
  • Looks like pyside-uic input -o output.py *should* do it but doesn't actually output runnable Python for some reason fyi. – NoBugs Apr 16 '18 at 07:11
0

I had the same problem and then realized that I have modified the .pro file manually: that is I made "illegal" thing - moved mainwindow.ui under DISTFILES (by default all ui files are grouped under FORMS).

Returned back to FORMS and now everything works fine

0

This happened to me when I deleted elements from my form in the designer, but still had those elements referenced in the .cpp file. After I deleted those references in .cpp I was able to rebuild and the compiler stopped complaining.

BDeC
  • 27
  • 8