How to generate ui_*.h files in Visual Studio



  • I started a new Qt project in Visual Studio. Then I clicked on Rebuild Solution and now all the header files from my various UI component have been deleted. How can I get Visual Studio to recreate these?

    Visual Studio is reporting errors like:

    1>------ Build started: Project: Goldfinch, Configuration: Debug x64 ------
    1>Goldfinch.cpp
    1>main.cpp
    1>PropertiesViewer.cpp
    1>moc_Goldfinch.cpp
    1>d:\dev\starling2\game\2019\goldfinchqt\goldfinch\ui\propertiesviewer.h(4): fatal error C1083: Cannot open include file: 'ui_PropertiesViewer.h': No such file or directory (compiling source file ui\PropertiesViewer.cpp)
    1>d:\dev\starling2\game\2019\goldfinchqt\goldfinch\ui\propertiesviewer.h(4): fatal error C1083: Cannot open include file: 'ui_PropertiesViewer.h': No such file or directory (compiling source file .\GeneratedFiles\Debug\moc_Goldfinch.cpp)
    1>d:\dev\starling2\game\2019\goldfinchqt\goldfinch\ui\propertiesviewer.h(4): fatal error C1083: Cannot open include file: 'ui_PropertiesViewer.h': No such file or directory (compiling source file Goldfinch.cpp)
    1>moc_PropertiesViewer.cpp
    1>d:\dev\starling2\game\2019\goldfinchqt\goldfinch\ui\propertiesviewer.h(4): fatal error C1083: Cannot open include file: 'ui_PropertiesViewer.h': No such file or directory (compiling source file main.cpp)
    1>d:\dev\starling2\game\2019\goldfinchqt\goldfinch\ui\propertiesviewer.h(4): fatal error C1083: Cannot open include file: 'ui_PropertiesViewer.h': No such file or directory (compiling source file .\GeneratedFiles\Debug\moc_PropertiesViewer.cpp)
    1>Done building project "Goldfinch.vcxproj" -- FAILED.
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    

  • Moderators

    @kitfox ui_*.h headers are generated by uic tool.
    Delete old build folder, run qmake and build.



  • How do you run qmake?



  • qmake is an alternative to the Visual studio build system.
    Did you install the Qt Visual Studio Addin from the Addin Manager of VS?



  • The Addin Manager no longer seems to be part of Visual Studio. I did install the Qt Visual Studio Tools, but I don't know if that includes the tool you're referring to.


  • Moderators

    @kitfox said in How to generate ui_*.h files in Visual Studio:

    Qt Visual Studio Tools

    I guess you're not using qmake then (I don't use Visual Studio). Then delete build folder and build.



  • @kitfox said in How to generate ui_*.h files in Visual Studio:

    The Addin Manager no longer seems to be part of Visual Studio

    Sorry, now it's called "extensions and updates"



  • The Qt Visual Studio Tools are installed and I was using them earlier to create a new project. I don't see anything in there about qmake, though. Do you know how to run it?

    Which folder is the build folder? I've deleted x64/Debug which seems to contain everything generated during the build, but when I do a build after that I get the error message I posted above.



  • @kitfox said in How to generate ui_*.h files in Visual Studio:

    I don't see anything in there about qmake

    qmake is the build system used by Qt Creator, it is not used by Visual Studio.

    Unfortunately I'm not aware of a way to convert a VS project that was not created with the Qt VS Tools to one compatible so I'm afraid you need to rebuild your project from scratch using the Qt template


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.