当前位置:网站首页>QT interface optimization: QT border removal and form rounding
QT interface optimization: QT border removal and form rounding
2022-04-23 14:27:00 【Spiritual health】
Qt Interface optimization :Qt Border removal and form rounding
List of articles
One 、 design sketch
Two 、 Use steps
1. .h part
The code is as follows :
#include <QMovie>
#include <QLabel>
#include <QMouseEvent>
#include <QLine>
// Form rounding
#include <QBitmap>
#include <QPainter>
// The form can be dragged
private:
void mouseMoveEvent(QMouseEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
QPoint z;
private:
void Beawidget(); // Window interface optimization
2. .cpp part
The code is as follows :
Beawidget(); // Window interface optimization
// The window can be moved
void LoginWidget::mouseMoveEvent(QMouseEvent *event)
{
QWidget::mouseMoveEvent(event);
QPoint y =event->globalPos(); // The position of the mouse relative to the upper left corner of the desktop , Global mouse position
QPoint x =y-this->z;
this->move(x);
}
void LoginWidget::mousePressEvent(QMouseEvent *event)
{
QWidget::mousePressEvent(event);
QPoint y =event->globalPos(); // The mouse is relative to the upper left corner of the desktop , Global mouse position
QPoint x =this->geometry().topLeft(); // The position of the upper left corner of the window relative to the desktop , window position
this-> z =y-x ;// Constant value
}
void LoginWidget::mouseReleaseEvent(QMouseEvent *event)
{
QWidget::mouseReleaseEvent(event);
this->z=QPoint();
}
// Window interface optimization
void LoginWidget::Beawidget()
{
// Form border removal
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint);
this->setWindowTitle(" Yunxi Zhihua ");
// Form rounding
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);
}
版权声明
本文为[Spiritual health]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231411423094.html
边栏推荐
- c语言在结构体传参时参数压栈问题
- Qt界面优化:Qt去边框与窗体圆角化
- Golang 对分片 append 是否会共享数据
- JS progress bar, displaying the loading progress
- Basic regular expression
- 流程控制之分支语句
- 逻辑卷创建与扩容
- Nacos作为配置中心(四) 使用Demo
- source insight via samba
- I thought I could lie down and enter Huawei, but I was confused when I received JD / didi / iqiyi offers one after another
猜你喜欢
SHT11传感器的温度湿度监控报警系统单片机Proteus设计(附仿真+论文+程序等)
顺序表的操作,你真的学会了吗?
I thought I could lie down and enter Huawei, but I was confused when I received JD / didi / iqiyi offers one after another
流程控制之分支语句
单相交交变频器的Matlab Simulink建模设计,附Matlab仿真、PPT和论文等资料
关于UDP接收icmp端口不可达(port unreachable)
Qt实战:云曦聊天室篇
c语言在结构体传参时参数压栈问题
Thread group ThreadGroup uses introduction + custom thread factory class to implement threadfactory interface
DS1302的电子万年历_51单片机,年月日、星期、时分秒、农历和温度,带闹钟,全套资料
随机推荐
API Gateway/API 网关(三) - Kong的使用 - 限流rate limiting(redis)
Detailed explanation of SAR command
MySQL同步Could not find first log file name in binary log index file错误
On the insecurity of using scanf in VS
C语言知识点精细详解——数据类型和变量【2】——整型变量与常量【1】
ie8 浏览器提示是否 阻止访问js脚本
Parameter stack pressing problem of C language in structure parameter transmission
IE8 browser prompts whether to block access to JS script
Docker (V) MySQL installation
修改Firebase Emulators的默认侦听IP
tcp_diag 内核相关实现 1 调用层次
51单片机的花卉、农田自动浇水灌溉系统开发,Proteus仿真,原理图和C代码
JS progress bar, displaying the loading progress
Matrix exchange row and column
Matlab Simulink modeling and design of single-phase AC-AC frequency converter, with MATLAB simulation, PPT and papers
循环队列的基本操作,你学会了吗?
ssh限制登录的四种手段
基于单片机的DS18B20的数字温度监控报警系统设计【LCD1602显示+Proteus仿真+C程序+论文+按键设置等】
js 键值判断
初始c语言大致框架适合复习和初步认识