-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfrmmessagebox.cpp
More file actions
77 lines (67 loc) · 2.03 KB
/
frmmessagebox.cpp
File metadata and controls
77 lines (67 loc) · 2.03 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
#include "frmmessagebox.h"
#include "ui_frmmessagebox.h"
#include "iconhelper.h"
#include "myhelper.h"
frmMessageBox::frmMessageBox(QWidget *parent) :
QDialog(parent),
ui(new Ui::frmMessageBox)
{
ui->setupUi(this);
this->mousePressed = false;
//设置窗体标题栏隐藏
this->setWindowFlags(Qt::FramelessWindowHint);
//设置窗体关闭时自动释放内存
this->setAttribute(Qt::WA_DeleteOnClose);
//设置图形字体
IconHelper::Instance()->SetIcon(ui->lab_Ico, QChar(0xf015), 12);
IconHelper::Instance()->SetIcon(ui->btnMenu_Close, QChar(0xf00d), 10);
//关联关闭按钮
connect(ui->btnMenu_Close, SIGNAL(clicked()), this, SLOT(close()));
connect(ui->btnCancel, SIGNAL(clicked()), this, SLOT(close()));
//窗体居中显示
myHelper::FormInCenter(this);
}
frmMessageBox::~frmMessageBox()
{
delete ui;
}
void frmMessageBox::SetMessage(const QString &msg, int type)
{
if (type == 0) {
ui->labIcoMain->setStyleSheet("border-image: url(:/image/info.png);");
ui->btnCancel->setVisible(false);
ui->lab_Title->setText("提示");
} else if (type == 1) {
ui->labIcoMain->setStyleSheet("border-image: url(:/image/question.png);");
ui->lab_Title->setText("询问");
} else if (type == 2) {
ui->labIcoMain->setStyleSheet("border-image: url(:/image/error.png);");
ui->btnCancel->setVisible(false);
ui->lab_Title->setText("错误");
}
ui->labInfo->setText(msg);
}
void frmMessageBox::on_btnOk_clicked()
{
done(1);
this->close();
}
void frmMessageBox::mouseMoveEvent(QMouseEvent *e)
{
if (mousePressed && (e->buttons() && Qt::LeftButton)) {
this->move(e->globalPos() - mousePoint);
e->accept();
}
}
void frmMessageBox::mousePressEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton) {
mousePressed = true;
mousePoint = e->globalPos() - this->pos();
e->accept();
}
}
void frmMessageBox::mouseReleaseEvent(QMouseEvent *)
{
mousePressed = false;
}