2

I've created a Qt Application project in Visual Studio 2010. It contains the following files

Form Files
  mainwindow.ui
Header Files
  mainwindow.h
Source Files
  mainwindow.cpp

It also uses a generated codefile called ui_mainwindow.h. From what I've been able to discern, this file should be regenerated in response to changes made to the .ui file. However if I open the ui file in Designer and make a change, no change appears in the application.

I have to go to Form -> View Code -> Save As in Qt Designer and save the ui_mainwindow.h file manually.

Jesse Hallam
  • 6,794
  • 8
  • 48
  • 70
  • possible duplicate of [Qt - UI Files Not Updating in Visual Studio](http://stackoverflow.com/questions/8485230/qt-ui-files-not-updating-in-visual-studio) – Dmitry Egorov Jun 18 '15 at 07:35
  • To Future Coders: I found out that this doesn't work if you use Include-into-Class via Multiple Inheritance (in the Qt Widget Class-creation Wizard). But Include-into-Class via Member does work, so probably via Member-pointer does as well. Hope this helps. In other words, via Mutliple-inheritance, adding items to your Ui design in the Designer, and right-clicking the .ui file in the Solution explorer and hitting compile, and the items will not show up in your ui_*.h file. If you do it by member, they will. – MathCrackExchange Nov 28 '22 at 07:16

2 Answers2

1

.ui file should have custom build tool defined to use uic on it and produce appropriate ui_*.h file.

Custom build tool command line may look like this:

uic.exe "$(InputPath)" -o "ui_$(InputName).h"

Also, in order to properly detect dependencies and to Clean command remove generated file, add ui_$(InputName).h to Custom Build Tool Outputs.

Don't forget to make the changes for all Configurations and Platforms.

Although, the right way to do this would be to create appropriate .pro file and then generate Visual Studio project with qmake -tp vc project.pro. All compiler and linker settings should be adjusted in .pro file, not in Visual Studio project that should be regenerated after each change of .pro file.

Paul
  • 13,042
  • 3
  • 41
  • 59
0

i mean no offense but have you saved the .ui file before running the project?

when i need to edit the ui files, i change them with the designer and when i want to run it, it will recompile/moc/whatever the changed ui file and their .h/.cpp file as well.

Zaiborg
  • 2,492
  • 19
  • 28
  • Thanks for your response. I am indeed saving the .ui file in Designer, but do I need to reload the VS project every time I save the .ui file? – Jesse Hallam Oct 18 '12 at 15:15
  • no it should not be needed. vs should rebuild the ui-.h/.cpp files for your changed interface when you run it again – Zaiborg Oct 19 '12 at 06:19