资源简介
1、无边框窗体,自定义标题栏,鼠标拖动,大小缩放,双击切换;
2、自定义一个对话框,自动换行显示提示信息,可以很方便的调用;
3、自带提供了四种样式黑色、蓝色、灰色、天蓝色风格供选择
代码片段和文件信息
#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);
ui->comboBox_2->addItem(“black“);
ui->comboBox_2->addItem(“blue“);
ui->comboBox_2->addItem(“gray“);
ui->comboBox_2->addItem(“navy“);
}
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 frmMa
- 上一篇:嵌入式工程师面试宝典
- 下一篇:W5500PCB和原理图
相关资源
- 酒店管理系统基于Qt Creator5)
- vtk QT做的三维地质可视化系统2of2
- Qt局域网聊天软件
- Qt Creator opengl实现四元数鼠标控制轨迹
- QT局域网聊天系统(基于QT5.修改过)
- qt-电子点菜系统
- C 餐厅叫号系统(QT平)
- QT 实现文件下载
- qt图像处理
- 飞秋插件皮肤
- QT,JPEG解码源代码(已完成)
- Qt 播放音频文件
- Qt 读取16进制的data文件
- MQTT+串口(usart)透传
- 易语言QQTEA算法源码
- VC工程转Qt工程文件的工具
- MQTT推送Demo
- 基于Linux、QT的视频监控系统的设计与
- Qt 百度地图 定位
- QT酷炫界面开发指南《QmlBook》
- ssk皮肤
- Ubuntu下操作Excel,qt代码
- Qt图片浏览器 --基于Qt的Graphics View f
- qtnribbon2破解
- Qt软件开发 完整项目代码
- MQTT_3.1protocol_Specific中文版
- 在QT中使用RTP进行视频的采集和传输
- vclSkin5.6源码皮肤控件
- skin++2.1破解版
- VCLskin皮肤查看器
评论
共有 条评论