#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自定义精美换肤界面(转)
共34个文件
png:13个
css:4个
cpp:4个
5星 · 超过95%的资源 需积分: 42 346 下载量 65 浏览量
2016-05-05
12:01:51
上传
评论 12
收藏 716KB RAR 举报
温馨提示
1:无边框窗体,自定义标题栏,鼠标拖动,大小缩放,双击切换。 2:除了少量的几个图片资源外,几乎使用QSS写完所有颜色样式控制。 3:自定义一个QMessageBox对话框,自动换行显示提示信息,可以很方便的调用。 4:使用fontawesome图形字体库,将互联网的优秀资源应用于QT中。 5:彻底公开源码,可以任意随意使用。 6:QT各个版本都可以编译通过,亲测无误。 7:自带提供了四种样式黑色、蓝色、灰色、天蓝色风格供选择,可以自由更改image文件夹下的样式,也可以自己增加一些样式。
资源推荐
资源详情
资源评论
收起资源包目录
QTGUI.rar (34个子文件)
rc.qrc 835B
frmmain.h 836B
QUI.pro 643B
frmmessagebox.cpp 2KB
main.ico 355KB
frmmessagebox.h 716B
QUI.pro.user 23KB
main.rc 881B
main.cpp 461B
iconhelper.cpp 633B
myhelper.h 3KB
iconhelper.h 789B
image
add-line_horizontal.png 151B
radio_selected.png 1024B
sub-line_vertical.png 3KB
array_down.png 3KB
Font Awesome Cheatsheet.png 581KB
sub-line_horizontal.png 148B
checkbox_checked.png 691B
black.css 8KB
checkbox_unchecked.png 581B
question.png 4KB
gray.css 8KB
navy.css 8KB
blue.css 8KB
info.png 3KB
error.png 2KB
qt_zh_CN.qm 115KB
radio_normal.png 888B
add-line_vertical.png 3KB
fontawesome-webfont.ttf 138KB
frmmain.ui 16KB
frmmessagebox.ui 9KB
frmmain.cpp 3KB
共 34 条
- 1
rdagp
- 粉丝: 7
- 资源: 29
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页