当前位置:网站首页>Qt界面优化:Qt去边框与窗体圆角化
Qt界面优化:Qt去边框与窗体圆角化
2022-04-23 14:12:00 【ぃ灵彧が】
Qt界面优化:Qt去边框与窗体圆角化
一、效果图
二、使用步骤
1. .h部分
代码如下:
#include <QMovie>
#include <QLabel>
#include <QMouseEvent>
#include <QLine>
//窗体圆角化
#include <QBitmap>
#include <QPainter>
//窗体可拖动
private:
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
QPoint z;
private:
void Beawidget(); //窗口界面的优化
2. .cpp部分
代码如下:
Beawidget(); //窗口界面优化
//窗口可移动
void LoginWidget::mouseMoveEvent(QMouseEvent *event)
{
QWidget::mouseMoveEvent(event);
QPoint y =event->globalPos(); //鼠标相对于桌面左上角的位置,鼠标全局位置
QPoint x =y-this->z;
this->move(x);
}
void LoginWidget::mousePressEvent(QMouseEvent *event)
{
QWidget::mousePressEvent(event);
QPoint y =event->globalPos(); //鼠标相对于桌面左上角,鼠标全局位置
QPoint x =this->geometry().topLeft(); //窗口左上角相对于桌面位置,窗口位置
this-> z =y-x ;//定值不变
}
void LoginWidget::mouseReleaseEvent(QMouseEvent *event)
{
QWidget::mouseReleaseEvent(event);
this->z=QPoint();
}
//窗口界面优化
void LoginWidget::Beawidget()
{
//窗体去边框
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint);
this->setWindowTitle("云曦智划");
//窗体圆角化
QBitmap bmp(this->size());
bmp.fill();
QPainter p(&bmp);
p.setPen(Qt::NoPen);
p.setBrush(Qt::black);
p.drawRoundedRect(bmp.rect(),20,20);
setMask(bmp);
}
版权声明
本文为[ぃ灵彧が]所创,转载请带上原文链接,感谢
https://blog.csdn.net/m0_54754302/article/details/124342963
边栏推荐
- After entering the new company, the operation and maintenance engineer can understand the deployment of the system from the following items
- 剑指offer刷题(2)--面向华为
- 爬虫练习题(一)
- TUN 设备原理
- OpenSSH的升级、版本号的修改
- 贷款市场报价利率(LPR)与贷款基准利率介绍
- mysql 5.1升级到5.611
- Arrays类的使用案例
- yml引用其他变量
- API Gateway/API 网关(三) - Kong的使用 - 限流rate limiting(redis)
猜你喜欢
MySQL-InnoDB-事务
差分隐私(背景介绍)
使用开源调研工具Prophet是一种什么体验?
man man随记和crontab的@reboot用法
Processing MKDIR: unable to create directory 'AAA': read only file system
剑指offer刷题(2)--面向华为
统信UOS PHP7.2.3升级至PHP7.2.24
KVM学习资源
Tongxin UOS uninstall php7 2.24, install php7 4.27 ; Uninstall and then install PHP 7.2.34
Pass in external parameters to the main function in clion
随机推荐
差分隐私(背景介绍)
void*是怎样的存在?
LLVM - 生成 if-else 以及 PH
Use cases of the arrays class
错误:无法远程查找到密钥 “428F7ECC7117F726“
XX project structure notes
Nacos作为配置中心(四) 使用Demo
预览CSV文件
倒计时1天~2022云容灾产品线上发布会即将开始
How to do a project easily
mysql 5.1升级到5.611
JS progress bar, displaying the loading progress
man man随记和crontab的@reboot用法
Gif to still image processing
一些小小小小记录~
About the configuration and use of json5 in nodejs
Visio画拓扑图随记
JumpServer
mysql 5.1升级到5.66
LLVM - 生成for循环