I think this is a summary of what should happen.
1. start with an empty project. 2. Use the QT constructor to create the
mainwindow.ui file. 3. The qt creator should create the
ui_mainwindow.h header file for you, containing the necessary definitions for your user interface, as well as the member function functionUi (). The creator of QT creates this ui_mainwindow.h file by calling
uic (the user interface compiler) . 4. Now that you have this file, add this code to your project and I think that it will display your Qt GUI correctly. you can edit your GUI in Qt designer and recompile to show updated changes (I think) :)
#include "ui_mainwindow.h" #include <QMainWindow.h> #include <QApplication.h> int main(int argumentCount, char * argumentValues[]) { QApplication app(argumentCount, argumentValues); Ui::MainWindow ui; QMainWindow * myMainWindow= new QMainWindow(); ui.setupUi(myMainWindow); myMainWindow->show(); return app.exec(); }
ps: The Ui :: MainWindow class contains the setupUi () member function , which sets up a graphical interface for you.
Make sure you have the exact class name, because C ++ is case sensitive. Good luck.
Dr deo
source share