#include "frmmain.h"
#include "ui_frmmain.h"
#include "iconhelper.h"
#include "myhelper.h"
frmMain::frmMain(QWidget *parent) :
QDialog(parent),
ui(new Ui::frmMain)
{
ui->setupUi(this);
myHelper::FormInCenter(this);
this->InitStyle();
}
frmMain::~frmMain()
{
delete ui;
}
void frmMain::InitStyle()
{
//设置窗体标题栏隐藏
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint);
location = this->geometry();
max = false;
mousePressed = false;
//安装事件监听器,让标题栏识别鼠标双击
ui->lab_Title->installEventFilter(this);
IconHelper::Instance()->SetIcon(ui->btnMenu_Close, QChar(0xf00d), 12);
IconHelper::Instance()->SetIcon(ui->btnMenu_Max, QChar(0xf096), 10);
IconHelper::Instance()->SetIcon(ui->btnMenu_Min, QChar(0xf068), 10);
IconHelper::Instance()->SetIcon(ui->btnMenu, QChar(0xf0c9), 10);
IconHelper::Instance()->SetIcon(ui->lab_Ico, QChar(0xf015), 12);
}
bool frmMain::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseButtonDblClick) {
this->on_btnMenu_Max_clicked();
return true;
}
return QObject::eventFilter(obj, event);
}
void frmMain::mouseMoveEvent(QMouseEvent *e)
{
if (mousePressed && (e->buttons() && Qt::LeftButton) && !max) {
this->move(e->globalPos() - mousePoint);
e->accept();
}
}
void frmMain::mousePressEvent(QMouseEvent *e)
{
if (e->button() == Qt::LeftButton) {
mousePressed = true;
mousePoint = e->globalPos() - this->pos();
e->accept();
}
}
void frmMain::mouseReleaseEvent(QMouseEvent *)
{
mousePressed = false;
}
void frmMain::on_btnMenu_Close_clicked()
{
qApp->exit();
}
void frmMain::on_btnMenu_Max_clicked()
{
if (max) {
this->setGeometry(location);
IconHelper::Instance()->SetIcon(ui->btnMenu_Max, QChar(0xf096), 10);
ui->btnMenu_Max->setToolTip("最大化");
} else {
location = this->geometry();
this->setGeometry(qApp->desktop()->availableGeometry());
IconHelper::Instance()->SetIcon(ui->btnMenu_Max, QChar(0xf079), 10);
ui->btnMenu_Max->setToolTip("还原");;
}
max = !max;
}
void frmMain::on_btnMenu_Min_clicked()
{
this->showMinimized();
}
void frmMain::on_pushButton_clicked()
{
myHelper::ShowMessageBoxInfo("恭喜你获得我公司送出的1000万元大礼一份!");
}
void frmMain::on_pushButton_2_clicked()
{
int result = myHelper::ShowMessageBoxQuesion("确定真的不要我了吗?");
if (result == 1) {
myHelper::ShowMessageBoxInfo("你好狠心啊!");
} else {
myHelper::ShowMessageBoxInfo("亲爱的,我就知道你不会离开我的!");
}
}
void frmMain::on_pushButton_3_clicked()
{
myHelper::ShowMessageBoxError("天空飘来五个字!");
}
void frmMain::on_comboBox_currentIndexChanged(int index)
{
switch(index)
{
case 0:
myHelper::SetStyle("black");
break;
case 1:
myHelper::SetStyle("blue");
break;
case 2:
myHelper::SetStyle("gray");
break;
case 3:
myHelper::SetStyle("navy");
break;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Qt 实现界面换肤功能
共36个文件
png:13个
cpp:4个
css:4个
需积分: 44 38 下载量 92 浏览量
2018-01-03
11:48:50
上传
评论
收藏 720KB RAR 举报
温馨提示
Qt实现无边框界面鼠标拖动,换肤功能,标题栏双击放大缩小,自定义对话框,引用fontawesome-webfont图形字体,非常不错的代码学习
资源推荐
资源详情
资源评论
收起资源包目录
QUI.rar (36个子文件)
QUI
main.ico 355KB
iconhelper.cpp 633B
QUI.pro.user.3.0-pre1 17KB
image
checkbox_unchecked.png 581B
navy.css 8KB
array_down.png 3KB
checkbox_checked.png 691B
Font Awesome Cheatsheet.png 581KB
sub-line_vertical.png 3KB
question.png 4KB
sub-line_horizontal.png 148B
blue.css 8KB
info.png 3KB
black.css 8KB
radio_selected.png 1024B
gray.css 8KB
qt_zh_CN.qm 115KB
add-line_horizontal.png 151B
add-line_vertical.png 3KB
radio_normal.png 888B
fontawesome-webfont.ttf 138KB
error.png 2KB
QUI.pro.user.00f55cf.15 23KB
iconhelper.h 789B
frmmain.ui 17KB
rc.qrc 835B
frmmessagebox.cpp 2KB
myhelper.h 3KB
frmmessagebox.ui 9KB
frmmessagebox.h 716B
frmmain.h 892B
frmmain.cpp 3KB
main.cpp 461B
QUI.pro 643B
main.rc 881B
QUI.pro.user 18KB
共 36 条
- 1
资源评论
h595636059
- 粉丝: 14
- 资源: 39
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功