资源简介
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天气预报
- qt聊天室程序
- Qt绘制sin函数静态波形
- Qt异或实现文件加解密.rar
- EncryptQtDemo.rar
- QT等待对话框
- QT5串口上位机源代码
- qml 用item自定义dialog 对话框
- PyQt入门指南
- 汽车仪表盘
- qt做的小程序-鼠标事件
-
Qt Remote ob
ject(QtRO)进程间通信De - 基于QT扫雷游戏开发
- 解决QTextEdit右键菜单为英文的问题
- Qt QRCode生成二维码,完整代码可运行
- mqtt前端调用
- Ubuntu系统:为Qt配置ROS开发环境
- QT4编写的简单计算器
- Qt编写的Leds以及蜂鸣器奏乐
- 用Qt控制开发板led和蜂鸣器
- QT下Mingw实现QTtableview中实现添加复选
-
xm
l在Qt中三种方法解析的简单 - Linux下的Socket聊天系统,QT完整界面
- Linux下的QT车牌识别门禁系统基于ope
- 基于QT的方块消除游戏
- QT视频教程高清,用于QT的自学
- qtcreator-4.10.2的designer汉化包.zip
- qt自定义日历
- QML界面小
- qt编写的GPS界面
评论
共有 条评论