Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt5 | uic.exe | msys2 | ui_* will not generate
QtWS25 Last Chance

Qt5 | uic.exe | msys2 | ui_* will not generate

Scheduled Pinned Locked Moved Solved Installation and Deployment
uicmsys2ui designqt5qmake
10 Posts 4 Posters 1.7k 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.
  • V Offline
    V Offline
    VikingOfValhalla
    wrote on 20 Aug 2022, 16:29 last edited by VikingOfValhalla
    #1

    Synopsis of issue:

    • after processing 1) qmake 2) make, no ui_mainwindow.h file is being generated:
    make[1]: Entering directory '/c/Developer/GitHub/cpp_bug_tracker'
    g++ -c -fno-keep-inline-dllexport -march=x86-64 -mtune=generic -Wa,-mbig-obj -O2 -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -I..\..\cpp\msys64\mingw64\include\QtWidgets -I..\..\cpp\msys64\mingw64\include\QtGui -I..\..\cpp\msys64\mingw64\include\QtCore -Irelease -I/include -I..\..\cpp\msys64\mingw64\share\qt5\mkspecs\win32-g++  -o release\mainwindow.o mainwindow.cpp
    mainwindow.cpp:3:10: fatal error: ui_mainwindow.h: No such file or directory
       3 | #include "ui_mainwindow.h"
         |          ^~~~~~~~~~~~~~~~~
    compilation terminated.
    
    • File Structure:
    ├── Makefile
    ├── Makefile.Debug
    ├── Makefile.Release
    ├── README.md
    ├── bug_tracker_diagram.drawio
    ├── current_design_status.png
    ├── debug
    ├── main.cpp
    ├── main.pro
    ├── mainwindow.cpp
    ├── mainwindow.h
    └── release
        └── main.o
    
    • mainwindow.h:
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    #include <QPushButton>
    #include <QAbstractTableModel>
    
    
    
    namespace Ui {
      class MainWindow;
    }
    
    
    class TestModel : public QAbstractTableModel
    {
        Q_OBJECT
    
    public:
        TestModel(QObject *parent = 0);
    
        void populateData(const QList<QString> &contactName,const QList<QString> &contactPhone);
    
        int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
        int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
    
        QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
        QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
    
    private:
        QList<QString> tm_contact_name;
        QList<QString> tm_contact_phone;
    
    };
    
    
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
        public:
            explicit MainWindow(QWidget *parent = nullptr);
            ~MainWindow();
        private slots:
            void handleButton();
        private:
            QPushButton *m_button_1;
            QPushButton *m_button_2;
            QPushButton *m_button_3;
            QPushButton *m_button_4;
    
            Ui::MainWindow *ui;
    };
    #endif // MAINWINDOW_H
    
    • main.pro
    TEMPLATE = app
    TARGET = cpp_bug_tracker
    QT += core gui widgets
    SOURCES += main.cpp mainwindow.cpp
    HEADERS += mainwindow.h
    FORM += mainwindow.ui
    
    • mainwindow.cpp (only the important parts):
    
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    
    MainWindow::MainWindow(QWidget *parent) :
                        QMainWindow(parent), ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
    
        // Create button_1, make "this" the parent
        m_button_1 = new QPushButton("Submit Ticket", this);
        m_button_1->setGeometry(QRect(QPoint(20, 20), QSize(200, 50))); // size & loc
        connect(m_button_1, &QPushButton::released, this, &MainWindow::handleButton); // connect to slot
    
        // Create button_2, make "this" the parent
        m_button_2 = new QPushButton("Delete Ticket", this); // create button
        m_button_2->setGeometry(QRect(QPoint(20, 70), QSize(200, 50))); // size & loc
        connect(m_button_2, &QPushButton::released, this, &MainWindow::handleButton); // connect to slot
    
        // Create button_2, make "this" the parent
        m_button_3 = new QPushButton("Update Ticket", this); // create button
        m_button_3->setGeometry(QRect(QPoint(20, 120), QSize(200, 50))); // size & loc
        connect(m_button_3, &QPushButton::released, this, &MainWindow::handleButton); // connect to slot
    
        // Create button_2, make "this" the parent
        m_button_4 = new QPushButton("Assign Ticket", this); // create button
        m_button_4->setGeometry(QRect(QPoint(20, 170), QSize(200, 50))); // size & loc
        connect(m_button_4, &QPushButton::released, this, &MainWindow::handleButton); // connect to slot
    
    
        // lists
        QList<QString> contactNames;
        QList<QString> contactPhoneNums;;
    
        // Data
        contactNames.append("Rob");
        contactNames.append("Bob");
        contactNames.append("Tom");
        contactPhoneNums.append("32132321");
        contactPhoneNums.append("32155644");
        contactPhoneNums.append("13245648");
    
        // Create model:
        TestModel *PhoneBookModel = new TestModel(this);
    
        // Populate model with data:
        PhoneBookModel->populateData(contactNames,contactPhoneNums);
    
        // Connect model to table view:
        ui->tableView->setModel(PhoneBookModel);
    
        // Make table header visible and display table:
        ui->tableView->horizontalHeader()->setVisible(true);
        ui->tableView->show();
    
    }
    

    Development Environment:

    • C++
    • Library was downloaded through msys2 with:
      • pacman -S mingw-w64-x86_64-qt5 (Version: 5.15.3-1)
    • uic.exe exists within msys64\mingw64\bin directory.
    • Compiling through qmake & make.

    Does anyone have any idea why ui_mainwindow.h is not being generated?

    I've reviewed the qt5 docs:

    • https://doc.qt.io/qt-5/uic.html : If you use qmake, uic will be invoked automatically for header files.

    Any help would be greatly appreciated.

    Thank you!
    -Tom

    J 1 Reply Last reply 20 Aug 2022, 16:36
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 20 Aug 2022, 16:36 last edited by
      #2

      Hi and welcome to devnet,

      It's FORMS. You have it wrong (at least in what you posted).

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      V 1 Reply Last reply 20 Aug 2022, 16:51
      1
      • V VikingOfValhalla
        20 Aug 2022, 16:29

        Synopsis of issue:

        • after processing 1) qmake 2) make, no ui_mainwindow.h file is being generated:
        make[1]: Entering directory '/c/Developer/GitHub/cpp_bug_tracker'
        g++ -c -fno-keep-inline-dllexport -march=x86-64 -mtune=generic -Wa,-mbig-obj -O2 -Wall -Wextra -Wextra -fexceptions -mthreads -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I. -I..\..\cpp\msys64\mingw64\include\QtWidgets -I..\..\cpp\msys64\mingw64\include\QtGui -I..\..\cpp\msys64\mingw64\include\QtCore -Irelease -I/include -I..\..\cpp\msys64\mingw64\share\qt5\mkspecs\win32-g++  -o release\mainwindow.o mainwindow.cpp
        mainwindow.cpp:3:10: fatal error: ui_mainwindow.h: No such file or directory
           3 | #include "ui_mainwindow.h"
             |          ^~~~~~~~~~~~~~~~~
        compilation terminated.
        
        • File Structure:
        ├── Makefile
        ├── Makefile.Debug
        ├── Makefile.Release
        ├── README.md
        ├── bug_tracker_diagram.drawio
        ├── current_design_status.png
        ├── debug
        ├── main.cpp
        ├── main.pro
        ├── mainwindow.cpp
        ├── mainwindow.h
        └── release
            └── main.o
        
        • mainwindow.h:
        #ifndef MAINWINDOW_H
        #define MAINWINDOW_H
        
        #include <QMainWindow>
        #include <QPushButton>
        #include <QAbstractTableModel>
        
        
        
        namespace Ui {
          class MainWindow;
        }
        
        
        class TestModel : public QAbstractTableModel
        {
            Q_OBJECT
        
        public:
            TestModel(QObject *parent = 0);
        
            void populateData(const QList<QString> &contactName,const QList<QString> &contactPhone);
        
            int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
            int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
        
            QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
            QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
        
        private:
            QList<QString> tm_contact_name;
            QList<QString> tm_contact_phone;
        
        };
        
        
        
        class MainWindow : public QMainWindow
        {
            Q_OBJECT
            public:
                explicit MainWindow(QWidget *parent = nullptr);
                ~MainWindow();
            private slots:
                void handleButton();
            private:
                QPushButton *m_button_1;
                QPushButton *m_button_2;
                QPushButton *m_button_3;
                QPushButton *m_button_4;
        
                Ui::MainWindow *ui;
        };
        #endif // MAINWINDOW_H
        
        • main.pro
        TEMPLATE = app
        TARGET = cpp_bug_tracker
        QT += core gui widgets
        SOURCES += main.cpp mainwindow.cpp
        HEADERS += mainwindow.h
        FORM += mainwindow.ui
        
        • mainwindow.cpp (only the important parts):
        
        #include "mainwindow.h"
        #include "ui_mainwindow.h"
        
        
        MainWindow::MainWindow(QWidget *parent) :
                            QMainWindow(parent), ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
        
        
            // Create button_1, make "this" the parent
            m_button_1 = new QPushButton("Submit Ticket", this);
            m_button_1->setGeometry(QRect(QPoint(20, 20), QSize(200, 50))); // size & loc
            connect(m_button_1, &QPushButton::released, this, &MainWindow::handleButton); // connect to slot
        
            // Create button_2, make "this" the parent
            m_button_2 = new QPushButton("Delete Ticket", this); // create button
            m_button_2->setGeometry(QRect(QPoint(20, 70), QSize(200, 50))); // size & loc
            connect(m_button_2, &QPushButton::released, this, &MainWindow::handleButton); // connect to slot
        
            // Create button_2, make "this" the parent
            m_button_3 = new QPushButton("Update Ticket", this); // create button
            m_button_3->setGeometry(QRect(QPoint(20, 120), QSize(200, 50))); // size & loc
            connect(m_button_3, &QPushButton::released, this, &MainWindow::handleButton); // connect to slot
        
            // Create button_2, make "this" the parent
            m_button_4 = new QPushButton("Assign Ticket", this); // create button
            m_button_4->setGeometry(QRect(QPoint(20, 170), QSize(200, 50))); // size & loc
            connect(m_button_4, &QPushButton::released, this, &MainWindow::handleButton); // connect to slot
        
        
            // lists
            QList<QString> contactNames;
            QList<QString> contactPhoneNums;;
        
            // Data
            contactNames.append("Rob");
            contactNames.append("Bob");
            contactNames.append("Tom");
            contactPhoneNums.append("32132321");
            contactPhoneNums.append("32155644");
            contactPhoneNums.append("13245648");
        
            // Create model:
            TestModel *PhoneBookModel = new TestModel(this);
        
            // Populate model with data:
            PhoneBookModel->populateData(contactNames,contactPhoneNums);
        
            // Connect model to table view:
            ui->tableView->setModel(PhoneBookModel);
        
            // Make table header visible and display table:
            ui->tableView->horizontalHeader()->setVisible(true);
            ui->tableView->show();
        
        }
        

        Development Environment:

        • C++
        • Library was downloaded through msys2 with:
          • pacman -S mingw-w64-x86_64-qt5 (Version: 5.15.3-1)
        • uic.exe exists within msys64\mingw64\bin directory.
        • Compiling through qmake & make.

        Does anyone have any idea why ui_mainwindow.h is not being generated?

        I've reviewed the qt5 docs:

        • https://doc.qt.io/qt-5/uic.html : If you use qmake, uic will be invoked automatically for header files.

        Any help would be greatly appreciated.

        Thank you!
        -Tom

        J Offline
        J Offline
        JonB
        wrote on 20 Aug 2022, 16:36 last edited by
        #3

        @VikingOfValhalla

        • I don't see any mainwindow.ui file anywhere in the hierarchy you show.
        • FORM += mainwindow.ui I have no idea, maybe it shoudl be FORMS, or something else plural like for SOURCES/HEADERS??
        V 1 Reply Last reply 20 Aug 2022, 17:02
        2
        • S SGaist
          20 Aug 2022, 16:36

          Hi and welcome to devnet,

          It's FORMS. You have it wrong (at least in what you posted).

          V Offline
          V Offline
          VikingOfValhalla
          wrote on 20 Aug 2022, 16:51 last edited by
          #4

          Hi @SGaist , and thank you for the warm welcome!

          I adjusted to FORMS, I didn't notice that before so thank you for that. I was tinkering with it for quite a while before posting this so it's entirely possible on the last adjustment of my .pro file I made a typo.

          However, after adjusting FORMS it does seem to output a different error:

          C:\Developer\GitHub\cpp_bug_tracker>qmake
          WARNING: Failure to find: mainwindow.ui
          WARNING: Failure to find: mainwindow.ui
          
          C:\Developer\GitHub\cpp_bug_tracker>C:\Developer\cpp\msys64\usr\bin\make.exe
          /usr/bin/make -f Makefile.Release
          make[1]: Entering directory '/c/Developer/GitHub/cpp_bug_tracker'
          make[1]: *** No rule to make target 'mainwindow.ui', needed by 'ui_mainwindow.h'.  Stop.
          make[1]: Leaving directory '/c/Developer/GitHub/cpp_bug_tracker'
          make: *** [Makefile:45: release] Error 2
          
          C 1 Reply Last reply 20 Aug 2022, 16:52
          0
          • V VikingOfValhalla
            20 Aug 2022, 16:51

            Hi @SGaist , and thank you for the warm welcome!

            I adjusted to FORMS, I didn't notice that before so thank you for that. I was tinkering with it for quite a while before posting this so it's entirely possible on the last adjustment of my .pro file I made a typo.

            However, after adjusting FORMS it does seem to output a different error:

            C:\Developer\GitHub\cpp_bug_tracker>qmake
            WARNING: Failure to find: mainwindow.ui
            WARNING: Failure to find: mainwindow.ui
            
            C:\Developer\GitHub\cpp_bug_tracker>C:\Developer\cpp\msys64\usr\bin\make.exe
            /usr/bin/make -f Makefile.Release
            make[1]: Entering directory '/c/Developer/GitHub/cpp_bug_tracker'
            make[1]: *** No rule to make target 'mainwindow.ui', needed by 'ui_mainwindow.h'.  Stop.
            make[1]: Leaving directory '/c/Developer/GitHub/cpp_bug_tracker'
            make: *** [Makefile:45: release] Error 2
            
            C Offline
            C Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on 20 Aug 2022, 16:52 last edited by
            #5

            @VikingOfValhalla said in Qt5 | uic.exe | msys2 | ui_* will not generate:

            WARNING: Failure to find: mainwindow.ui

            As you can see there is no 'mainwindow.ui' in your source directory.

            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
            0
            • J JonB
              20 Aug 2022, 16:36

              @VikingOfValhalla

              • I don't see any mainwindow.ui file anywhere in the hierarchy you show.
              • FORM += mainwindow.ui I have no idea, maybe it shoudl be FORMS, or something else plural like for SOURCES/HEADERS??
              V Offline
              V Offline
              VikingOfValhalla
              wrote on 20 Aug 2022, 17:02 last edited by
              #6

              Hi @JonB, yes that is correct. The mainwindow.ui should be generated by uic.exe per the documentation posted above: https://doc.qt.io/qt-5/uic.html
              However, that is the problem I'm encountrering. I did need to make an adjustment to the FORMS per both your reply and @SGaist above. Please see additional error output as a result of the change that I posted a moment ago.

              C 1 Reply Last reply 20 Aug 2022, 17:10
              0
              • V VikingOfValhalla
                20 Aug 2022, 17:02

                Hi @JonB, yes that is correct. The mainwindow.ui should be generated by uic.exe per the documentation posted above: https://doc.qt.io/qt-5/uic.html
                However, that is the problem I'm encountrering. I did need to make an adjustment to the FORMS per both your reply and @SGaist above. Please see additional error output as a result of the change that I posted a moment ago.

                C Offline
                C Offline
                Christian Ehrlicher
                Lifetime Qt Champion
                wrote on 20 Aug 2022, 17:10 last edited by
                #7

                @VikingOfValhalla said in Qt5 | uic.exe | msys2 | ui_* will not generate:

                The mainwindow.ui should be generated by uic.exe per the documentation

                No, you have to create it with the Qt designer. Or do you think the ui is generated automagically?

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

                V 1 Reply Last reply 20 Aug 2022, 17:19
                0
                • C Christian Ehrlicher
                  20 Aug 2022, 17:10

                  @VikingOfValhalla said in Qt5 | uic.exe | msys2 | ui_* will not generate:

                  The mainwindow.ui should be generated by uic.exe per the documentation

                  No, you have to create it with the Qt designer. Or do you think the ui is generated automagically?

                  V Offline
                  V Offline
                  VikingOfValhalla
                  wrote on 20 Aug 2022, 17:19 last edited by VikingOfValhalla
                  #8

                  @Christian-Ehrlicher thanks for the response!
                  Yes I did think it would be created automatically.
                  Is there a way to create it without having to use Qt Designer? I tried searching for the documentation on how to create .ui files but I'm only finding the Qt Designer.
                  I would prefer to not need to use a gui when developing this small type of program (I can see a need for complex programs). It's part of the reason I'm not using Qt Creator.

                  Thanks!

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on 20 Aug 2022, 17:22 last edited by Christian Ehrlicher
                    #9

                    Then don't use a ui file and create the ui programatically by adding your widgets to a layout and showing them in a QWidget/QDialog/QMainWindow.

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

                    V 1 Reply Last reply 20 Aug 2022, 17:31
                    3
                    • C Christian Ehrlicher
                      20 Aug 2022, 17:22

                      Then don't use a ui file and create the ui programatically by adding your widgets to a layout and showing them in a QWidget/QDialog/QMainWindow.

                      V Offline
                      V Offline
                      VikingOfValhalla
                      wrote on 20 Aug 2022, 17:31 last edited by
                      #10

                      @Christian-Ehrlicher thank you for your help :)

                      1 Reply Last reply
                      0

                      8/10

                      20 Aug 2022, 17:19

                      • Login

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