Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Running UIC on .ui files on Visual Studio
Qt 6.11 is out! See what's new in the release blog

Running UIC on .ui files on Visual Studio

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thaxila
    wrote on last edited by
    #1

    I have a complicated Qt Widgets GUI written on Linux.
    To compile it with Visual Studio for Windows, I created a Visual Studio Project From Existing Code. After the project was created, I added in the .ui form files to the project.

    When I compile the project, uic does not run and the ui_ headers and moc files are not being created. Consequently, the project does not find the ui_ headers.

    How can I configure Visual Studio 2022 to make it run the Qt uic on the .ui files in the project as a build step please?

    Pl45m4P 1 Reply Last reply
    0
    • T Thaxila

      I have a complicated Qt Widgets GUI written on Linux.
      To compile it with Visual Studio for Windows, I created a Visual Studio Project From Existing Code. After the project was created, I added in the .ui form files to the project.

      When I compile the project, uic does not run and the ui_ headers and moc files are not being created. Consequently, the project does not find the ui_ headers.

      How can I configure Visual Studio 2022 to make it run the Qt uic on the .ui files in the project as a build step please?

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @Thaxila

      Use a build system like CMake and/or add the Qt VS Tools for Visual Studio 2022 to your VS Plugins.

      For CMake, see

      • https://cmake.org/cmake/help/latest/prop_tgt/AUTOUIC.html
      • https://cmake.org/cmake/help/latest/prop_tgt/AUTOMOC.html

      Don't you use CMake for your Linux build?! Why not use the same configuration (well or at least similar when there is OS specific stuff)?

      @Thaxila said in Running UIC on .ui files on Visual Studio:

      After the project was created, I added in the .ui form files to the project.

      Also: Include the *.ui files in your project, don't just move them afterwards


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Thaxila
        wrote on last edited by
        #3

        I added the Qt Visual Studio Tools which is supposed to automatically run the uic compiler on all .ui files. But it doesn't. I ended up adding a pre-build event to manually run uic on each .ui form.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bonnie
          wrote on last edited by
          #4

          Are the .ui files correctly catalogued as "Form Files" in the solution explorer? What's your Qt Project Settings?
          Years ago when I was using quite old Qt & VS I had met similar problem and clear/reset the Qt version in the project setting could solve that. Not sure if this would work on your case.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Thaxila
            wrote on last edited by
            #5

            I had to manually add the form files. It is supposed to recognize the .ui extension. The project didn't.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved