#include "testview.h" #include "ui_testview.h" TestView::TestView(QWidget *parent) : QMainWindow(parent), ui(new Ui::TestView) { ui->setupUi(this); this->initForm(); } TestView::~TestView() { delete ui; } void TestView::initForm() { QPushButton *button1 = new QPushButton("Button 1"); QPushButton *button2 = new QPushButton("Button 2"); ui->horizontalLayout_2->addWidget(button1); ui->horizontalLayout_2->addWidget(button2); ui->horizontalLayout_2->setStretchFactor(button1,1); ui->horizontalLayout_2->setStretchFactor(button2,2); this->setWindowTitle("软件标题"); this->setWindowFlags(Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint); this->setWindowFlag(Qt::CustomizeWindowHint,true); this->setWindowFlag(Qt::WindowSystemMenuHint,true); }