-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmainwindow.cpp
43 lines (33 loc) · 1.07 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "mainwindow.h"
#include "MessageBox.h"
#include "ComboBox/combobox.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QDebug>
MainWidget::MainWidget(QWidget *parent)
: QWidget(parent)
{
QPushButton *msgDialog = new QPushButton("MessageBox");
m_statusBar = new QLabel;
ComboBox *comboBox = new ComboBox();
comboBox->setMaximumSize(100,40);
QHBoxLayout *dailogLayout = new QHBoxLayout();
dailogLayout->addWidget(msgDialog,0,Qt::AlignLeft);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addLayout(dailogLayout);
layout->addWidget(comboBox, 0, Qt::AlignLeft);
layout->addWidget(m_statusBar, 0, Qt::AlignBottom);
connect(msgDialog, &QPushButton::clicked, this, &MainWidget::showMsgBox);
}
MainWidget::~MainWidget()
{
}
void MainWidget::showMsgBox()
{
MessageBox msgBox("信息","这是一个简单的自定义message box",this);
msgBox.exec();
qDebug() << msgBox.result();
QString &&res = QString("已选择:");
m_statusBar->setText(res+(msgBox.result()==1?"确定":"取消"));
}