#ifndef UI_Window
#define UI_Window
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QMainWindow>
#include <QtWidgets/QMenuBar>
#include <QtWidgets/QStatusBar>
#include <QtWidgets/QToolBar>
#include <QtWidgets/QWidget>
#include <QtWidgets/QLabel>
class Ui_Window
{
public:
QMenuBar *menuBar;
QToolBar *mainToolBar;
QWidget *centralWidget;
QStatusBar *statusBar;
QLabel* label;//模范他,加label控件
void setupUi(QMainWindow* p2User_Window)
{
if (p2User_Window->objectName().isEmpty())
p2User_Window->setObjectName(QStringLiteral("p2User_Window"));
p2User_Window->resize(400, 300);
menuBar = new QMenuBar(p2User_Window);
menuBar->setObjectName(QStringLiteral("menuBar"));
p2User_Window->setMenuBar(menuBar);
mainToolBar = new QToolBar(p2User_Window);
mainToolBar->setObjectName(QStringLiteral("mainToolBar"));
p2User_Window->addToolBar(mainToolBar);
centralWidget = new QWidget(p2User_Window);
centralWidget->setObjectName(QStringLiteral("centralWidget"));
p2User_Window->setCentralWidget(centralWidget);
statusBar = new QStatusBar(p2User_Window);
statusBar->setObjectName(QStringLiteral("statusBar"));
p2User_Window->setStatusBar(statusBar);
label = new QLabel("Hello Qt",centralWidget);//label控件设置为Hello Qt,父窗口是centralWidget
retranslateUi(p2User_Window);
QMetaObject::connectSlotsByName(p2User_Window);
}// setupUi
void retranslateUi(QMainWindow *p2User_Window)
{
p2User_Window->setWindowTitle(QApplication::translate("p2User_Window", "p2User_Window", 0));
} // retranslateUi
};
#endif // UI_Window
#ifndef USER_WINDOW_H
#define USER_WINDOW_H
#include <QMainWindow>
#include "Ui_Window.h"
class User_Window : public QMainWindow
{
Q_OBJECT
private:
Ui_Window *ui;
public:
User_Window(QWidget *parent = 0);
~User_Window();
};
#endif // USER_WINDOW_H
#include "User_Window.h"
User_Window::User_Window(QWidget *parent) : QMainWindow(parent)
{
ui = new Ui_Window;
ui->setupUi(this);
}
User_Window::~User_Window()
{
delete ui;
}
#include "User_Window.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
User_Window w;
w.show();
return app.exec();
}