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. Basic Question - Regenerating a new ui_programname.h file
Forum Updated to NodeBB v4.3 + New Features

Basic Question - Regenerating a new ui_programname.h file

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 1.3k 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.
  • U Offline
    U Offline
    Uberlinc
    wrote on last edited by
    #1

    Hi,

    So, working through Blanchette & Summerfield.
    After creating a gui interface filled with widgets in the GUI editor, how do you force it to update the code after you make a change to the GUI?
    I tried running qmake again - No joy.

    Also, when you run qmake, it seems to create an entire file structure, which then creates said ui_programname.h.
    In my case, it made it completely outside the file structure of my particular project.
    Are you then expected to manually copy the ui_programname.h to your own file structure and add it manually?
    If not, are there settings in the Qt IDE to make this happen?

    Many thanks.

    Uberlinc.

    1 Reply Last reply
    0
    • U Offline
      U Offline
      Uberlinc
      wrote on last edited by
      #2

      Edit: I found that qmake wasn't updating the file because I had it open elsewhere in Notepad++.
      However, it still re-generated it in the file structure aside from my main project.

      Can this be changed?
      Are you then required to move the file to your own file structure prior to recompiling?
      How does this work?

      Thanks.

      Uberlinc.

      1 Reply Last reply
      0
      • Christian EhrlicherC Online
        Christian EhrlicherC Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @uberlinc said in Basic Question - Regenerating a new ui_programname.h file:

        which then creates said ui_programname.h.

        The ui_foo.h is not created by qmake but by uic during make. Since there is a dependency, the ui_foo.h is rebuild once the foo.ui file changes. But you can also simply remove the ui_foo.h file to be sure.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        3
        • U Offline
          U Offline
          Uberlinc
          wrote on last edited by
          #4

          Thank you for this.

          So, the uic will create ui_foo.h but always in a completely different file structure?
          Are you required to move this file?
          Can you leave it where it is?
          Are there options in the IDE that will configure uic to create these files within your project (for neatness etc.)?

          Thanks.

          mrjjM 1 Reply Last reply
          0
          • U Uberlinc

            Thank you for this.

            So, the uic will create ui_foo.h but always in a completely different file structure?
            Are you required to move this file?
            Can you leave it where it is?
            Are there options in the IDE that will configure uic to create these files within your project (for neatness etc.)?

            Thanks.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            Hi

            • So, the uic will create ui_foo.h but always in a completely different file structure?-
              Its created in the build folder, just like any other build file.

            Are you required to move this file?
            Nope.
            Can you leave it where it is?
            Indeed. There is no reason to do anything with it.

            Are there options in the IDE that will configure uic to create these files within your project (for neatness etc.)?
            you can tell where UIC should place it with
            UI_DIR = xxxx
            https://doc.qt.io/qt-5/qmake-variable-reference.html

            however, i don't see anything neat about having it in the project folder as they build artifacts and belong in the build folder. :)

            Whenever you change the UI file, its ui_xxx files is generated again so in most cases you can simply
            ignore these files, just like .o files and the other files that are generated.

            The "outside the file structure of my particular project." is called a build folder and "work" files are put there during compile and linking.

            1 Reply Last reply
            2
            • U Offline
              U Offline
              Uberlinc
              wrote on last edited by
              #6

              Thanks, mrjj.
              Those are pretty full and comprehensive answers to my questions.

              One more: If this file is somewhat ignorable, are required to #include them in any particular file?
              If so, then which file path do you specify or do you simply not qualify a path and it knows where to pick it up?

              Thanks again.

              1 Reply Last reply
              0
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi
                Normally they are auto inserted into the corresponding cpp file
                #include "ui_mainwindow.h"
                where the .h will use a forward declaration
                namespace Ui {
                class MainWindow;
                }

                This happens automatically if you use the Wizard and select
                alt text

                you get both ui/cpp/and h file with it all setup and nothing more is needed.

                However, if you manually build by hand every file then yes, you would have to
                include it manually.

                1 Reply Last reply
                2
                • U Offline
                  U Offline
                  Uberlinc
                  wrote on last edited by
                  #8

                  Thank you very much, mrjj,

                  You've been wonderfully helpful!

                  1 Reply Last reply
                  1

                  • Login

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