How to show the mainwindow.ui

  • I am new to QT. I've just created a pro project and added Form Class. I designed my mainwindow.ui but how should I show that? I want to start the app with that windows? I am a mac user.

  • You can install "QtCreator": and create new project with QtCreator and you'll see realisation of such application.

    Here is the default defenition of MainWindow with form created by QtCreator


    #include <QtGui/QApplication>
    #include "mainwindow.h"

    int main(int argc, char *argv[])
    QApplication a(argc, argv);
    MainWindow w;;

    return a.exec&#40;&#41;;


    Header mainwinwow.h:

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    namespace Ui {
    class MainWindow;

    class MainWindow : public QMainWindow

    explicit MainWindow(QWidget *parent = 0);

    Ui::MainWindow *ui;

    #endif // MAINWINDOW_H

    Source mainwindow.h:

    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent) :
    ui(new Ui::MainWindow)

    delete ui;

    and file:



    Project created by QtCreator 2011-11-02T08:56:38


    QT += core gui

    TARGET = MainWindow
    TEMPLATE = app

    SOURCES += main.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui

    P.S. -QT- it's QuickTime so it is Qt

  • I am using QTCreator, but tell me how to show my main window.ui instead of main.qml

  • If you are using qml, you should stay in qml, especially at the beginning.

    Seems, you created a Qt Quick project (which is qml).
    For starting with Qt, I suggest creating a "normal" Qt project, like
    Qt-Widget-Project --> Qt-Gui_...

  • I am writing a compiler. It's finished. I want to create GUI. I've choose QT because it has Ubuntu output. I'm good at C++. Why should I stay at QML?

  • Your posts states that you created something with qml. If you created a "normal" qt gui project based on a main w9indow, it would work out of the box ;-)

  • I changed it to the GUI widget but i don't know how to manage my objects. for example; I want to change the text box text when the button is pressed. Bot of them are created and there s function for the pushButton when pressed

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.