-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmessageboxdialog.cpp
More file actions
110 lines (95 loc) · 3.54 KB
/
Copy pathmessageboxdialog.cpp
File metadata and controls
110 lines (95 loc) · 3.54 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "messageboxdialog.h"
#include <QMessageBox>
MessageBoxDialog::MessageBoxDialog(QWidget *parent):
QDialog(parent)
{
setWindowTitle("标准消息对话框");
label = new QLabel;
label->setText("请选择一种消息对话框");
QuestionMesageBtn = new QPushButton;
QuestionMesageBtn->setText("QuestionMesage");
InformationMessageBtn = new QPushButton;
InformationMessageBtn->setText("InformationMessage");
WarningMesageBtn = new QPushButton;
WarningMesageBtn->setText("WarningMesage");
CriticalMesageBtn = new QPushButton;
CriticalMesageBtn->setText("CriticalMesage");
AboutMesageBtn = new QPushButton;
AboutMesageBtn->setText("AboutMesage");
AboutQtMesageBtn = new QPushButton;
AboutQtMesageBtn->setText("AboutQtMesage");
mainLayout = new QGridLayout(this);
mainLayout->addWidget(label, 0, 0, 1, 2);
mainLayout->addWidget(QuestionMesageBtn, 1, 0);
mainLayout->addWidget(InformationMessageBtn, 1, 1);
mainLayout->addWidget(WarningMesageBtn, 2, 0);
mainLayout->addWidget(CriticalMesageBtn, 2, 1);
mainLayout->addWidget(AboutMesageBtn, 3, 0);
mainLayout->addWidget(AboutQtMesageBtn, 3, 1);
connect(QuestionMesageBtn, SIGNAL(clicked(bool)), this, SLOT (ShowQuestionMesage()));
connect(InformationMessageBtn, SIGNAL(clicked(bool)), this, SLOT (ShowInformationMesage()));
connect(WarningMesageBtn, SIGNAL(clicked(bool)), this, SLOT (ShowWarningMesage()));
connect(CriticalMesageBtn, SIGNAL(clicked(bool)), this, SLOT (ShowCriticalMesage()));
connect(AboutMesageBtn, SIGNAL(clicked(bool)), this, SLOT (ShowAboutMesage()));
connect(AboutQtMesageBtn, SIGNAL(clicked(bool)), this, SLOT (ShowAboutQtMesage()));
}
void MessageBoxDialog::ShowQuestionMesage()
{
label->setText("Question Message Box");
switch (QMessageBox::question(this, "Question 消息框", "您现在已经修改完成,是否要结束程序", QMessageBox::Ok|QMessageBox::Cancel, QMessageBox::Ok))
{
case QMessageBox::Ok:
label->setText("Question button/Ok");
break;
case QMessageBox::Cancel:
label->setText("Question button/Cancel");
break;
default:
break;
}
return;
}
void MessageBoxDialog::ShowInformationMesage()
{
label->setText("Information Message Box");
QMessageBox::information(this, "Inforation 消息框", "这是Information消息框");
return;
}
void MessageBoxDialog::ShowWarningMesage()
{
label->setText("Warning Message Box");
switch (QMessageBox::warning(this, "Warning 消息框", "您现在经修改的内容未保存,是否要结束本次修改?",
QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel, QMessageBox::Save))
{
case QMessageBox::Save:
label->setText("Warning button/Save");
break;
case QMessageBox::Discard:
label->setText("Warning button/Discard");
break;
case QMessageBox::Cancel:
label->setText("Warning button/Cancel");
break;
default:
break;
}
return;
}
void MessageBoxDialog::ShowCriticalMesage()
{
label->setText("Critical Message Box");
QMessageBox::critical(this, "Critical 消息框", "这是Critical消息框");
return;
}
void MessageBoxDialog::ShowAboutMesage()
{
label->setText("About Message Box");
QMessageBox::about(this, "About 消息框", "这是About消息框");
return;
}
void MessageBoxDialog::ShowAboutQtMesage()
{
label->setText("About Message Box");
QMessageBox::aboutQt(this, "AboutQt 消息框");
return;
}