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. Control the location of (ui_*.h) files with CMake
Forum Updated to NodeBB v4.3 + New Features

Control the location of (ui_*.h) files with CMake

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 1.9k Views
  • 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.
  • SavizS Offline
    SavizS Offline
    Saviz
    wrote on last edited by Saviz
    #1

    Is there a way to specify/define the location where "ui_*.h" files (such as ui_mainwindow.h) will be generated by the CMakeLists.txt file?

    ############################### EDIT #########################################

    Since my question is causing a lot of confusion and problems, I decided to give some more explanation :)

    It all started with me making a decision to make my self more familiar with the structure of a Qt project. I made a simple project and named it "QtProject". I attempted to understand the folder structure of the project in depth. The biggest issue that I had was the following code:

    #include "mainwindow.h"
    #include "./ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    

    The above is the standard code that comes with nearly every project in a QWidget application for the mainwindow.cpp file. My issue in particular is the following include line:

    #include "./ui_mainwindow.h"
    

    The above include line really confused me since I could not figure out where it was placed in relation to the mainwindow.cpp file. As far as I am aware, the path of "./" is referring to the current directory. But, I never found the header file near my mainwindow.cpp file. I eventually found it under the path of "QtProject_autogen\include". This path was confusing to me, so I wanted to ask kindly if there is a way to specify where it will place this file.

    jsulmJ 1 Reply Last reply
    0
    • SavizS Saviz

      Is there a way to specify/define the location where "ui_*.h" files (such as ui_mainwindow.h) will be generated by the CMakeLists.txt file?

      ############################### EDIT #########################################

      Since my question is causing a lot of confusion and problems, I decided to give some more explanation :)

      It all started with me making a decision to make my self more familiar with the structure of a Qt project. I made a simple project and named it "QtProject". I attempted to understand the folder structure of the project in depth. The biggest issue that I had was the following code:

      #include "mainwindow.h"
      #include "./ui_mainwindow.h"
      
      MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      

      The above is the standard code that comes with nearly every project in a QWidget application for the mainwindow.cpp file. My issue in particular is the following include line:

      #include "./ui_mainwindow.h"
      

      The above include line really confused me since I could not figure out where it was placed in relation to the mainwindow.cpp file. As far as I am aware, the path of "./" is referring to the current directory. But, I never found the header file near my mainwindow.cpp file. I eventually found it under the path of "QtProject_autogen\include". This path was confusing to me, so I wanted to ask kindly if there is a way to specify where it will place this file.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Saviz Is there a reason why you want to control that? These files are autogenerated and thus put in build folder.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      SavizS 1 Reply Last reply
      2
      • jsulmJ jsulm

        @Saviz Is there a reason why you want to control that? These files are autogenerated and thus put in build folder.

        SavizS Offline
        SavizS Offline
        Saviz
        wrote on last edited by
        #3

        @jsulm I know this may not be a very convincing answer to your question, but I am just simply curious. I may want to specify a custom location for them just for the sake of keeping my project organized the way I want it to :)

        Christian EhrlicherC 1 Reply Last reply
        1
        • SavizS Saviz

          @jsulm I know this may not be a very convincing answer to your question, but I am just simply curious. I may want to specify a custom location for them just for the sake of keeping my project organized the way I want it to :)

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by Christian Ehrlicher
          #4

          @Saviz said in Control the location of (ui_*.h) files with CMake:

          just for the sake of keeping my project organized the way I want it to :)

          No, it's not possible and why would someone organize the temporary build folder?

          /edit: you can modify them a little bit with AUTOGEN_BUILD_DIR

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

          JoeCFDJ 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            @Saviz said in Control the location of (ui_*.h) files with CMake:

            just for the sake of keeping my project organized the way I want it to :)

            No, it's not possible and why would someone organize the temporary build folder?

            /edit: you can modify them a little bit with AUTOGEN_BUILD_DIR

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #5

            @Christian-Ehrlicher ui files have layout info and sometimes people do need to take a look at them. qmake has UI_DIR for this. The build dir made by cmake is sort of messy and not intuitive. That is why I have both qmake and cmake in my apps. In my qmake file I use OBJECTS_DIR, MOC_DIR and UI_DIR to organize build output.

            Christian EhrlicherC SavizS 2 Replies Last reply
            2
            • JoeCFDJ JoeCFD

              @Christian-Ehrlicher ui files have layout info and sometimes people do need to take a look at them. qmake has UI_DIR for this. The build dir made by cmake is sort of messy and not intuitive. That is why I have both qmake and cmake in my apps. In my qmake file I use OBJECTS_DIR, MOC_DIR and UI_DIR to organize build output.

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by Christian Ehrlicher
              #6

              @JoeCFD said in Control the location of (ui_*.h) files with CMake:

              ui files have layout info and sometimes people do need to take a look at them

              QtCreator: Go to the source where the header is included and move the cursor to the include, press F2
              Put your cursor to a ui element, press F2

              You really want to tell me that searching the file in a directory is faster than this?

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

              JoeCFDJ 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                @JoeCFD said in Control the location of (ui_*.h) files with CMake:

                ui files have layout info and sometimes people do need to take a look at them

                QtCreator: Go to the source where the header is included and move the cursor to the include, press F2
                Put your cursor to a ui element, press F2

                You really want to tell me that searching the file in a directory is faster than this?

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by JoeCFD
                #7

                @Christian-Ehrlicher I mainly work from command line on Linux. I simply want to make my build dir look a bit cleaner. Speed is another issue.

                Christian EhrlicherC 1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @Christian-Ehrlicher I mainly work from command line on Linux. I simply want to make my build dir look a bit cleaner. Speed is another issue.

                  Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @JoeCFD said in Control the location of (ui_*.h) files with CMake:

                  I mainly work from command line on Linux.

                  Speed is another issue.

                  So you want to tell me you're faster programming on the command line than in a good IDE? No need to discuss further...

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

                  JoeCFDJ 1 Reply Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    @JoeCFD said in Control the location of (ui_*.h) files with CMake:

                    I mainly work from command line on Linux.

                    Speed is another issue.

                    So you want to tell me you're faster programming on the command line than in a good IDE? No need to discuss further...

                    JoeCFDJ Offline
                    JoeCFDJ Offline
                    JoeCFD
                    wrote on last edited by JoeCFD
                    #9

                    @Christian-Ehrlicher Where did you get this? Why does it matter who is faster or not. I am not working with you. I said I want to keep my build dir cleaner since I work more from command line. If you work with qtcreator all the time, you may not care about how the build dir looks like.

                    1 Reply Last reply
                    2
                    • JoeCFDJ JoeCFD

                      @Christian-Ehrlicher ui files have layout info and sometimes people do need to take a look at them. qmake has UI_DIR for this. The build dir made by cmake is sort of messy and not intuitive. That is why I have both qmake and cmake in my apps. In my qmake file I use OBJECTS_DIR, MOC_DIR and UI_DIR to organize build output.

                      SavizS Offline
                      SavizS Offline
                      Saviz
                      wrote on last edited by
                      #10

                      @JoeCFD I completely agree with your opinion. Thank you for your explanation.

                      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