QtCreator Build doesn't update UI changes in design form - qt

My Qt project uses shadow build.
When I change in MainWindow form ( .ui file), I build the project but my program doesn't update GUI.
If I rebuild all, GUI will be updated. But rebuild is very very slow.
I try creating a new project (an empty QMainWindow with some labels), I modify some texts. I build and GUI is updated.
How can I use shadow build correctly, without a rebuild of all my project?

The same issue occurs if the *.ui file name is changed.
For example, Changing yourUi.ui to myUi.ui.
If that is the scenario, then the ui_*.h should also be changed, that is, yourUi.ui to ui_myUi.h.

close Qt creator, go to your project directory and delete the .pro.user file, open the project again and this time Qt creator will ask you to configure your project by choosing the kit you use to build your project. Select the appropriate kit and press the "configure project" button. Apply your shadow build. I hope it will work.

Have you tried to just run qmake (Build -> Run qmake) ?
Edit
As suggested by a comment, I copied the comment to preserve it.
It seems that QtCreator correctly rebuild the .h file of the ui in the shadow build directory, and then include the ones in the source directory, which is not regenerated. I don't know if this is a bug or an intended behaviour, but a quick workaround can be to build the project in the shadow build directory, copy the generated .h files back in the source directory and rebuild again. This work with my simple project, don't know if can be workable also for bigger and more complex project. Or do not use shadow builds

Related

how build the qt project itself using qtcreator

Update:
Because this was partly to have a project to code-browse the whole of qt, here is a much better way to do this: Code Browser by Woboq for C & C++
This even lets you browse into the includes outside the project like the system includes or the standard library.
Old Post:
My question is about Qt project in git://code.qt.io/qt/qt5.git repository. I checked out version 5.12.
My assumption is that qtcreator knows the qmake file but nothing about the configure command. Hence
I used the configure command to prepare the build in a shadow build directory
In QTCreator I opened qt.pro located in the git workspace
QTCreator opens the build settings dialog and I import them from the shadow build directory
Finally I click build in QTCreator.
But the compile window stalls when asking me for input. Qmake asks me about the licence type I want to choose. I had answered that already in the configure phase and even if I would agree to answer the question again, there is no prompt function in qtcreator's compile output window. Where did I go wrong?
If I forget about QTCreator and call make in the shadow build directory, then everything is build fine and without any licensing questions. When I then import the shadow build directory into a QTCreator, then I can build in QTCreator. But then I clicked Run qmake out of curiosity and I was back to square one, i.e. compile window asks me for input again and stops there forever.
Apart from my specific question I found no general documentation about building the qt libraries using QTCreator. I only find descriptions about compiling projects that use the Qt library.
Qt is not really meant to be compiled from within an IDE. However, this does not mean it's impossible to do. There are two ways to archive this:
First approach: Add the developer build as custom kit:
Run the configure script (and add the -developer-build option)
Open QtCreator and go to "Tools > Options > Kits"
Go to "Qt Versions" add press "Add" - select the qmake executable generated by the configure script. Then hit "Apply"
Go to "Kits" and press "Add" - Make shure to select the correct compilers and debugger and select the previously create "Qt Version". Press "Ok"
Open the top level .pro file in QtCreator and choose the previously created Kit. QtCreator will now use the correct qmake executable
This is the "proper" way to go. You can now use the project as any normal project, including changes to pro-files. Also, QtCreator now correctly detects the build directory, so you won't have to change that, even when opening one of the modules.
Second approach: Use as a normal project without qmake:
Run the configure script (and add the -developer-build option)
Run make qmake_all in the same terminal to let Qt prepare all makefiles, create headers etc.
Open the top level .pro file in QtCreator. You can choose any kit.
Go to Project > Your Kit > Build and disable the "qmake" step (the first of the default 2 steps)
Change the "build directory" to be wherever you built Qt - either a shadow build or the source directory
Hit Build and QtCreator will invoke make only, archieving the same behaviour as running make from the console.
This is kind of a workaround and I would not recommend using it for a full Qt build, unless the first approach does not work for you for whatever reason.
This can also be useful if you only want to make changes to a single Qt module, without compiling the whole Qt framework, i.e. you can clone one of the submodules and use your "existing" qmake on it instead of compiling QtBase (in that case, you skip step 4)
Final notice: When I tried opening the whole Qt-Project, QtCreator crashed on my system because the project was to big to handle. I would recommend you to only open one of the modules within the super repostitory, i.e. "qtbase", "qtdeclarative", etc.

Why do I need to remove build directory after changing something in a Qt .pro file?

Every single time I change something in a Qt .pro file (add a new source file, change compile flags, etc...), my changes do not take effect. I am using Qt Creator. The same thing happens on windows (MSVC compiler) and Mac. If i remove build directory, it's ok then. (not counting wasted time for full rebuild)
Could be a bug but as it sounds so trivial it rather feels like I am missing something.
Thanks!
When you change somethng in a *.pro file, you have to re-run qmake on the project, to refresh the files in Qt Creator. You don't need to delete your build folder every time.
But when you delete the build folder, Qt automatically run qmake on the project before running the compilation. Your solution works, but it's a bit overkill ;)
This menu is also available when right-clicking on the project

How to tell QT creator to parse .pro file when I build after changing it?

I'm using qt 5.3 under windows 7. Every time I edit the .pro file I need to clean up Makefile file under output/building folder to make it re-parse the changed pro file. I want it automatically detect the change when I hit build or run.
Is there some config I miss-set?
Three ways to re-parse the .pro file:
Right-click the project name in the Project pane (the topmost item) and select Run qmake
Click the Build/Run qmake menu option
Edit the .pro file, press Ctrl-S, and let Qt Creator automatically reparse it
It sounds like the third option is what you want and it's not working for you. It has traditionally been flakey and I never rely on it -- I use the first technique, right-clicking the Project and choosing Run qmake.

Why qt creates this folder

I've created qt project called calculator so the file path on my disc is:
C:\excercizes\QT_projects\calculator
but qt created another extra directory next to it, which looks like:
C:\excercizes\QT_projects\Calculator-build-desktop-Qt_4_7_4_for_Desktop_-_MinGW_4_4__Qt_SDK__Debug
What for is this directory? I see inside it two folders called debug and release but even when I build this project in release mode nothing is placed there, instead folders debug and release inside the first directory mentioned are used.
Anyone knows?
It's shadow building. You can desactivate that if you want.
http://doc.qt.io/qtcreator/creator-glossary.html#glossary-shadow-build

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?
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
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.
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.
This is what helped me personally, add to qmake file:
UI_DIR = $$PWD
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.
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.
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
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.
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.
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).
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.
Add the following line into .pro file
UI_DIR = $$PWD
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)
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
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.

Resources