#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), 10);
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("天空飘来五个字!");
}
没有合适的资源?快使用搜索试试~ 我知道了~
QT:qss样式设置按类非常经典源码
共34个文件
png:13个
h:4个
cpp:4个
4星 · 超过85%的资源 需积分: 50 118 下载量 191 浏览量
2016-03-08
16:11:53
上传
评论 5
收藏 728KB ZIP 举报
温馨提示
QUI.zip为源代码共享,里面有各种Qss的书写及使用,及setStyle()的使用
资源推荐
资源详情
资源评论
收起资源包目录
QUI.zip (34个子文件)
QUI
frmmessagebox.ui 9KB
main.ico 355KB
myhelper.h 3KB
frmmessagebox.h 716B
iconhelper.h 789B
main.rc 881B
rc.qrc 835B
frmmain.h 836B
iconhelper.cpp 633B
frmmain.cpp 3KB
image
blue.css 8KB
question.png 4KB
error.png 2KB
sub-line_vertical.png 3KB
gray.css 8KB
black.css 8KB
add-line_vertical.png 3KB
fontawesome-webfont.ttf 138KB
info.png 3KB
add-line_horizontal.png 151B
array_down.png 3KB
checkbox_checked.png 691B
qt_zh_CN.qm 115KB
Font Awesome Cheatsheet.png 581KB
radio_selected.png 1024B
checkbox_unchecked.png 581B
navy.css 8KB
radio_normal.png 888B
sub-line_horizontal.png 148B
QUI.pro.user 23KB
main.cpp 461B
QUI.pro 643B
frmmain.ui 16KB
frmmessagebox.cpp 2KB
共 34 条
- 1
资源评论
- zhang184442017-02-07可以借鉴使用!
- tanglinux2018-06-19可以借鉴使用!
- liuxuan199010102016-04-20可以借鉴使用!
- hychyc_20082019-07-22可以用,学习了
smile飞雪
- 粉丝: 0
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功