How to update code after an ui modification? - qt

I'm working on a Qt Gui Project with Visual Studio 2019. I changed a button name in the ui designer and saved it, but when I go back to the code, the change hasn't been noticed. I would like to execute qmake but I can't find it.

Related

Start QT UI from Pycharm

My problem is that i installed QT Designer and also implemented QT as an external tool in my Pycharm. This means I can open QT by pressing Tools --> External Tools --> QTdesigner. I created a little test UI and safed it in my Projectdirectory. Now I convert this .ui file with pyside2-uic.exe. I posted this as a picture.
Now i can rightclick on my .ui file in my Project and choose under External Tools the PyUIC. It builds a .py file. So far so good. Here is my problem. Now I press run but nothing happens. I canĀ“t start the UI from here. What did I do wrong?

What causes qtcreator to stop updating ui header files

I find my QtCreator (v4.5.0) stops updating ui header filers (for one of my projects) when I add some elements in the ui design form.
For example, after I add some QLCDNumber objects in the mainwindow.ui, normally I should be able to set these objects in the mainwindow constructor, something like: ui->lcdNumber. But now the lcdNumber (QLCDNumber *lcdNumber) is not recognized since the ui_mainwindow.h has not update the definition for the newly added objects.
I tried to run qmake, or reopen the project I am working on, or even restart my computer. It still doesn't work. It is noted that the issues is true of all the ui forms created within this project.
It is also weird to observe that other projects work fine. Anyone has idea of why this happens? Thanks!
I found the solution to the issue here Qt designer does not update the gui. What I have done is to delete all the previously built results, and configuration project built with Shaw build. Then the QtCreator returns to normal. Alternatively, delete all the previous ui_header files and rebuild the project.

Compile .ui file (to .cpp and .h file) without full build in QtCreator

It's kinda surprising, but Qt seems to work much better with Visual Studio (with Qt add-on) than their own IDE, QtCreator.
In Visual Studio, right clicking an UI file in project view allows you to compile it, producing ui_something.h:
In QtCreator, I see no obvious way to build it. There is no button for it. Actually, there's a button in Build menu:
It compiles the project, while ui_main.h remains unchanged. I actually don't even know, how did I manage to generate the old ui_main.h, now outdated since I edited the form. There just seems no way, maybe apart from a command line solution.
In case this doesn't get a fully qualified answer, I'll just leave here that you can do it manually in command line:
uic main.ui>ui_main.h
uic prints the output on stdout, so you need to use > operator to save output in a file.

QtCreator Build doesn't update UI changes in design form

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

QtCreator Designer signal/slot connections inconsistent with generated code

I'm working on a Qt project in QtCreator. The project has a dialog box with several UI elements, some of which have to be enabled/disabled according to what the user does. (i.e. If the user selects a radio button, then the form field has to be enabled.)
When I add a new signal/slot connection or delete an existing through the Qt Designer tool, the change shows up just fine in the preview. When I compile the application, though, the window still behaves exactly as it did before.
I investigated this by checking out the ui_WindowName.h file that the Qt Designer creates. Near the end of the setupUi function is a set of connect() calls. These connect() calls are consistent with the slot and signals that existed earlier today, but they do not reflect the changes I have made through Qt Designer since.
If I manually change the ui_WindowName.h file, then the UI works. But, of course, my changes get overridden if I ever try to chance anything from Qt Designer.
Even when I quit QtCreator and open it again, the Designer still shows the changed slot/signal connections while the auto-generated code does not reflect the changes.
Am I doing something wrong? Is there some way to delete whatever cache the Designer is storing or something to get things back in sync?
Thanks!
(One other thing: I'm using the stand-alone Qt Creator, not trying to develop in Visual Studio. The only other similar problem I could find on the web was from someone developing in Visual Studio, which doesn't support the automated signal/slot stuff.)
As usual, the answer is obvious once you realize it.
I moved the project in the course of working on it. There's a .pro.user file that keeps track of where the project is located. Without realizing that, I moved it along with the rest of the files.
As a result, I was editing one copy of the project and running the other.
The moral of the story: If you move a Qt project, remember to update your .pro.user file.
(Or you can just delete it. Qt Creator will prompt you to re-create it when you open the project.)

Resources