当前位置:网站首页>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
边栏推荐
- Processing MKDIR: unable to create directory 'AAA': read only file system
- How does void * exist?
- Tongxin UOS php7 2.3 upgrade to php7.0 two point two four
- squid代理
- 统信UOS PHP7.2.3升级至PHP7.2.24
- 关于UDP接收icmp端口不可达(port unreachable)
- yml引用其他变量
- 贷款市场报价利率(LPR)与贷款基准利率介绍
- 使用开源调研工具Prophet是一种什么体验?
- Get the thread return value. Introduction to the use of future interface and futuretask class
猜你喜欢
TLS/SSL 协议详解 (30) SSL中的RSA、DHE、ECDHE、ECDH流程与区别
进入新公司,运维工程师从下面这几项了解系统的部署
MySQL-InnoDB-事务
Gartner预测云迁移规模大幅增长;云迁移的优势是什么?
Use the executors class to quickly create a thread pool
API gateway / API gateway (IV) - use of Kong - Integrated JWT and fuse plug-in
uni-app消息推送
ThreadGroup ThreadGroup implémente l'interface threadfactory en utilisant la classe Introduction + Custom thread Factory
线程组ThreadGroup使用介绍+自定义线程工厂类实现ThreadFactory接口
差分隐私(背景介绍)
随机推荐
Visio画拓扑图随记
grep无法重定向到文件的问题
API Gateway/API 网关(二) - Kong的使用 - 负载均衡Loadbalance
Gif to still image processing
KVM学习资源
快速搞懂线程实现的三种方式
LLVM - 生成for循环
MySQL基础知识
MySQL数据库讲解(九)
LLVM - 生成局部变量
Use the executors class to quickly create a thread pool
进入新公司,运维工程师从下面这几项了解系统的部署
浅谈skiplist在LevelDB的应用
统信UOS PHP7.2.3升级至PHP7.2.24
Docker (V) MySQL installation
IE8 browser prompts whether to block access to JS script
Thread group ThreadGroup uses introduction + custom thread factory class to implement threadfactory interface
GFS分布式文件系统(理论)
Algorithem_ReverseLinkedList
翻牌效果