Chris
Chris

Reputation: 541

Qt designer does not update the gui

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?

Upvotes: 53

Views: 39389

Answers (15)

BDeC
BDeC

Reputation: 37

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.

Upvotes: 0

Prayag k
Prayag k

Reputation: 678

Add the following line into .pro file

   UI_DIR = $$PWD

Upvotes: 1

nuncaeslupus
nuncaeslupus

Reputation: 41

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.

Upvotes: 1

Shota Meladze
Shota Meladze

Reputation: 1

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

Upvotes: 0

Raul Costa Junior
Raul Costa Junior

Reputation: 11

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).

Upvotes: 1

ironic
ironic

Reputation: 8949

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

Upvotes: 147

transistor
transistor

Reputation: 669

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)

Upvotes: 0

TAK
TAK

Reputation: 11

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.

Upvotes: 1

cen
cen

Reputation: 2943

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

Upvotes: 6

Crawl.W
Crawl.W

Reputation: 421

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.

Upvotes: 4

Liz
Liz

Reputation: 8958

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.

Upvotes: 9

AKstat
AKstat

Reputation: 384

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.

Upvotes: 1

user6284
user6284

Reputation: 171

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.

Upvotes: 17

maniax
maniax

Reputation: 11

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

Upvotes: 1

ishmael
ishmael

Reputation: 1906

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.

Upvotes: 2

Related Questions