-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessagebox.h
45 lines (39 loc) · 1.21 KB
/
messagebox.h
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
#ifndef MESSAGEBOX_H
#define MESSAGEBOX_H
#include <QApplication>
#include <QMessageBox>
class MessageBox {
public:
static void warning(const QString& title, const QString& text) {
QMessageBox msgBox;
msgBox.setWindowTitle(title);
msgBox.setText(text);
msgBox.setIcon(QMessageBox::Warning);
msgBox.exec();
}
static int question(const QString& title, const QString& text) {
QMessageBox msgBox;
msgBox.setWindowTitle(title);
msgBox.setText(text);
msgBox.setIcon(QMessageBox::Question);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
int ret = msgBox.exec();
return ret;
}
static void error(const QString& title, const QString& text) {
QMessageBox msgBox;
msgBox.setWindowTitle(title);
msgBox.setText(text);
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
}
static void errorQuit(const QString& title, const QString& text) {
QMessageBox msgBox;
msgBox.setWindowTitle(title);
msgBox.setText(text);
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
qApp->quit();
}
};
#endif // MESSAGEBOX_H