5 Star 17 Fork 18

sj0830 / qt_project

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
frmmessagebox.cpp 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
sj0830 提交于 2020-02-18 23:34 . 首次提交,建立基础开发版本;
#include "frmmessagebox.h"
#include "ui_frmmessagebox.h"
#include "iconhelper.h"
#include "myhelper.h"
#include "myapp.h"
#pragma execution_character_set("utf-8")
frmMessageBox::frmMessageBox(QWidget *parent) :
QDialog(parent),
ui(new Ui::frmMessageBox)
{
ui->setupUi(this);
this->InitStyle();
}
frmMessageBox::~frmMessageBox()
{
delete ui;
}
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;
}
void frmMessageBox::InitStyle()
{
this->setProperty("Form", true);
//窗体居中显示
myHelper::FormInCenter(this, myApp::DeskWidth, myApp::DeskHeight);
this->mousePressed = false;
//设置窗体标题栏隐藏
this->setWindowFlags(Qt::FramelessWindowHint);
//设置图形字体
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()));
}
void frmMessageBox::SetMessage(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);
this->setWindowTitle(ui->lab_Title->text());
}
void frmMessageBox::on_btnOk_clicked()
{
done(1);
this->close();
}
C/C++
1
https://gitee.com/sjsun/qt_project.git
git@gitee.com:sjsun/qt_project.git
sjsun
qt_project
qt_project
master

搜索帮助