当前位置:网站首页>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
边栏推荐
- Use of ansible and common modules
- C语言知识点精细详解——数据类型和变量【1】——进位计数制
- 处理 mkdir:无法创建目录“aaa“:只读文件系统
- PWM speed regulation control system of DC motor based on 51 single chip microcomputer (with complete set of data such as Proteus simulation + C program)
- 分分钟掌握---三目运算符(三元运算符)
- 1分钟看懂执行流程,永久掌握for循环(附for循环案例)
- Proteus simulation design of DC adjustable regulated power supply (with simulation + paper and other data)
- 循环队列的基本操作(实验)
- uni-app消息推送
- 51单片机+LCD12864液晶显示的俄罗斯方块游戏,Proteus仿真、AD原理图、代码、论文等
猜你喜欢
随机推荐
Web page, adaptive, proportional scaling
想要成为架构师?夯实基础最重要
交通灯系统51单片机设计(附Proteus仿真、C程序、原理图及PCB、论文等全套资料)
Processing MKDIR: unable to create directory 'AAA': read only file system
修改Firebase Emulators的默认侦听IP
ArrayList集合基本使用
Electronic scale weighing system design, hx711 pressure sensor, 51 single chip microcomputer (proteus simulation, C program, schematic diagram, thesis and other complete data)
c语言在结构体传参时参数压栈问题
顺序表的操作,你真的学会了吗?
爬虫练习题(一)
Notes on Visio drawing topology
redis的五种数据类型
顺序栈的基本操作
Gif to still image processing
Flop effect
TLS/SSL 协议详解 (28) TLS 1.0、TLS 1.1、TLS 1.2之间的区别
Use the executors class to quickly create a thread pool
编译Openssl
解决ssh配置文件优化以及连接慢的问题
JS format time