PDA

View Full Version : Change objectName in Designer does not get updated in Creator



GeneCode
21st September 2017, 03:19
I am working in a project and I open both Qt creator in one screen and in another monitor i open Qt designer.
When i change the widget's objectname and saved the ui, the completion code does not detect the new name.
the only way to make the changes reflect on creator is to restart the IDE. which is dumb. any way to avoid this
stupidity?:rolleyes:

high_flyer
21st September 2017, 12:29
The reason for this is that the changes in the designer form are saved to the *.ui file which is xml.
In order for QtCreator to be able to show you the changes in the code completion they have to take place in the C++ code as well.
For that you need to call the uic on the changed form to generate the new C++ code that include the changes from the *.ui file.
So simply building the project will work.
I am not aware of the option to run only uic separately directly from QtCreator but you can do it from the console like this:
uic -o my_form.h my_form.ui

MaksymS
24th September 2017, 19:51
Hi,
I have similar problem, hope anybody could help me.

When I change objectName of my QMainWindow at my *.ui file the *.h and *.cpp
files are not apdated automatically and when I try to RUN it I have the error.
I tried "clean" and "build" but the files are not updated!
I also tried uic command from console - did not help.
And when I change manually it works.

GeneCode
25th September 2017, 03:47
Hi,
I have similar problem, hope anybody could help me.

When I change objectName of my QMainWindow at my *.ui file the *.h and *.cpp
files are not apdated automatically and when I try to RUN it I have the error.
I tried "clean" and "build" but the files are not updated!
I also tried uic command from console - did not help.
And when I change manually it works.

So far what I did is restart Qt.
It is dumb, but that's the only thing that worked for me.
Maybe Qt is not meant to work when Qt Designer is opened
side by side with Creator. idk... it sucksssss

Ginsengelf
26th September 2017, 09:27
When I change objectName of my QMainWindow at my *.ui file the *.h and *.cpp
files are not apdated automatically and when I try to RUN it I have the error.


As high_flyer wrote, the designer edits an .ui file. The uic command converts this to the ui_xyz.h file, which is then included in your .h and .cpp files.
Neither the designer nor the uic will change your code!

Ginsengelf

GeneCode
26th September 2017, 11:06
So simply building the project will work.


Ok building does update the names.
I guess this is better than restarting Qt.

kiril
29th December 2020, 12:07
Well, looks like re-build is not enough: the object names are not updated in the .cpp file.
What am I missing?
Thanks in advance

d_stranz
29th December 2020, 17:29
What am I missing?

The object names (as well as any other settings made through Designer) are updated on the C++ side only when 1) you save the UI file from Designer, 2) the UIC compiler runs as part of the build process to convert the .ui file into the ui_*.h file that gets #included in the class declaration header file, 3) you are #include-ing the correct ui_*.h header file and not some previous version that is still hanging around because you renamed it without deleting the old one, and 4) your .pro file is set up to run UIC on all of the UI files needed.

Since you haven't provided any information other than "it doesn't work", it's hard to say what is wrong in your case.