Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to show the mainwindow.ui
Forum Updated to NodeBB v4.3 + New Features

How to show the mainwindow.ui

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 3 Posters 8.1k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    McFaraz
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rokemoon
      wrote on last edited by
      #2

      You can install "QtCreator":http://get.qt.nokia.com/qtcreator/qt-creator-mac-opensource-2.3.1.dmg 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


      main.cpp:

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

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

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

      }
      @


      Header mainwinwow.h:

      @
      #ifndef MAINWINDOW_H
      #define MAINWINDOW_H

      #include <QMainWindow>

      namespace Ui {
      class MainWindow;
      }

      class MainWindow : public QMainWindow
      {
      Q_OBJECT

      public:
      explicit MainWindow(QWidget *parent = 0);
      ~MainWindow();

      private:
      Ui::MainWindow *ui;
      };

      #endif // MAINWINDOW_H
      @


      Source mainwindow.h:

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

      MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
      {
      ui->setupUi(this);
      }

      MainWindow::~MainWindow()
      {
      delete ui;
      }
      @


      and mainwindow.pro file:

      @

      #-------------------------------------------------

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

      #-------------------------------------------------

      QT += core gui

      TARGET = MainWindow
      TEMPLATE = app

      SOURCES += main.cpp
      mainwindow.cpp

      HEADERS += mainwindow.h

      FORMS += mainwindow.ui
      @

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        McFaraz
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          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_...

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • M Offline
            M Offline
            McFaraz
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • G Offline
              G Offline
              giesbert
              wrote on last edited by
              #6

              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 ;-)

              Nokia Certified Qt Specialist.
              Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

              1 Reply Last reply
              0
              • M Offline
                M Offline
                McFaraz
                wrote on last edited by
                #7

                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

                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