Qt5 | uic.exe | msys2 | ui_* will not generate
-
wrote on 20 Aug 2022, 16:29 last edited by VikingOfValhalla
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 withinmsys64\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 - after processing 1)
-
Hi and welcome to devnet,
It's
FORMS
. You have it wrong (at least in what you posted). -
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 withinmsys64\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!
-Tomwrote on 20 Aug 2022, 16:36 last edited by- I don't see any
mainwindow.ui
file anywhere in the hierarchy you show. FORM += mainwindow.ui
I have no idea, maybe it shoudl beFORMS
, or something else plural like forSOURCES
/HEADERS
??
- after processing 1)
-
wrote on 20 Aug 2022, 16:51 last edited by
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
-
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
@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.
-
- I don't see any
mainwindow.ui
file anywhere in the hierarchy you show. FORM += mainwindow.ui
I have no idea, maybe it shoudl beFORMS
, or something else plural like forSOURCES
/HEADERS
??
wrote on 20 Aug 2022, 17:02 last edited byHi @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 theFORMS
per both your reply and @SGaist above. Please see additional error output as a result of the change that I posted a moment ago. - I don't see any
-
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 theFORMS
per both your reply and @SGaist above. Please see additional error output as a result of the change that I posted a moment ago.@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?
-
@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?
wrote on 20 Aug 2022, 17:19 last edited by VikingOfValhalla@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!
-
Lifetime Qt Championwrote on 20 Aug 2022, 17:22 last edited by Christian Ehrlicher
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.
-
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.
wrote on 20 Aug 2022, 17:31 last edited by@Christian-Ehrlicher thank you for your help :)
1/10