开发者

What is the use of setupUi(this) in Qt

开发者 https://www.devze.com 2023-04-06 11:45 出处:网络
I am new to Qt. I have downloaded a source from net. The header file contains the following #ifndef MAINWINDOW_H

I am new to Qt. I have downloaded a source from net.

The header file contains the following

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

       ainWindow>

namespace Ui {
   class MainWindow;
}

class MainWindow : public QMainWindow
{
      Q_OBJECT
      public:
    开发者_开发技巧     explicit MainWindow(QWidget *parent = 0);
         ~MainWindow();

      private:
         Ui::MainWindow *ui; // Need for this line. Any one please help
};

#endif // MAINWINDOW_H

in mainwindow.cpp file ui->setupUI(this) has been called in constructor. Please help what is the need for the creation of ui variable


You need a MainWindow.ui file which is then processed by Qt's UIC mechanism, which is triggered if you run qmake.

If you are using an IDE like Visual Studio with the Qt Plugin or Qt Creator, just create a new Qt GUI class through the wizard and you will have everything you need.

This page discusses usage of UI files in depth.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号