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
setupUi() creates the actual instances of widgets for you. A form that you create in QtDesigner is stored just as XML file.
ui file is used to create a ui_calculatorform. h file that can be used by any file listed in the SOURCES declaration. Note: You can use Qt Creator to create the Calculator Form project. It automatically generates the main.
To create a . ui file go to File -> New File or Project... In the window that appears select Qt under Files and Classes on the left, then select Qt Designer Form on the right. You'll notice the icon has "ui" on it, showing the type of file you're creating.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With