当前位置:网站首页>QT redraw events and cuts
QT redraw events and cuts
2022-04-23 12:15:00 【MechMaster】
Qt Some problems in drawing
1. Redraw events
- The reason for the redrawing event
- repaint() Function or update() Function called ;
- Hidden parts are now redisplayed ;
- Most components can simply redraw the entire interface , However, some parts that are slow to draw need to be optimized and only the needed areas need to be drawn ( have access to **QPaintEvent::region()** To get the area ), This speed optimization does not affect the results .
- Qt It will speed up drawing by merging multiple redrawing events into one event , When update() The function is called many times , Or when the window system sends multiple redrawing Events ,Qt These events will be merged into one event , And this time has the largest area that needs to be redrawn .
- **update()** The function does not redraw immediately , Wait until the Qt Only after returning to the dwell time cycle , So multiple calls update() Functions usually cause only one paintEvent() Function call .
- repaint() The function immediately calls paintEvent() Function to redraw parts , Only if you must redraw immediately ( For example, in animation ), Only use repaint() function .
- update() Function allows Qt Optimize speed and reduce flicker , however repaint() Functions don't support such optimizations .
- Never in **paintEvent()** Call in function update() and repaint()
- Here is the code to make the interface display darker colors :
setBackgroundRole(QPalette::Dark);
setAutoFillBackground(true);
2. shear
- QPainter You can cut any drawing operation , It can cut a rectangle 、 Content in an area or a path , This can be used separately **setClipRect()、setClipRegion()、setClipPath()** Function to implement .
- The following code cuts the text in a rectangle :
QPainter painter(this);
painter.setClipRect(10,0,20,10);
painter.drawText(10,10,tr("10086"));
3. Reading and writing images
- The easiest way to read an image is to use QImage and QPixmap Constructor for , Or call QImage::load() and QPixmap::load() function .
- Qt Medium QImageReader Class provides a format independent interface , You can read images from files or other devices . More control can be provided when reading images , If you use setScaledSize() Function to read the image in the specified size , You can also use setClipRect() Read an area of the image .
- QImageWriter Class is used to store images , It supports specific options for formatting images , Such as gamma level 、 Compression grade and quality, etc . If you don't need to set these options , Use it directly QImage::save() and **QImagePixmap::save()** Function .
版权声明
本文为[MechMaster]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231210423886.html
边栏推荐
- Purpose of IM expression (IM 5.2)
- Recommended programming AIDS: picture tool snipaste
- CGC: contractual graph clustering for community detection and tracking
- Xinwangda announced that the price of battery products had been increased, and the investment of "weixiaoli" exceeded 1 billion
- 远程访问家里的树莓派(上)
- [redis series] redis learning 13. Redis often asks simple interview questions
- The fourth chapter is about enabling and disabling the im column storage of table space for im enabled filling objects (IM 4.5)
- 数组---
- IDEA 代码格式化插件Save Actions
- 在 VSCode 中调试 Jest 的测试用例,VSCode调试Jest测试用例报错basedir=$(dirname “$(echo “$0“ | sed -e ‘s,\\,/,g‘)“)解决
猜你喜欢
Xinwangda announced that the price of battery products had been increased, and the investment of "weixiaoli" exceeded 1 billion

IFLYTEK's revenue in 2021 was 18.3 billion yuan: a year-on-year increase of 41% and a net profit of 1.556 billion yuan
欣旺达宣布电池产品涨价 此前获“蔚小理”投资超10亿

How to solve the computer system card?

软银愿景基金进军Web3安全行业 领投CertiK 6000万美元新一轮投资

亿级流量架构,服务器如何扩容?写得太好了!

Use kettle to copy records to and get records from results

【Redis 系列】redis 学习十三,Redis 常问简单面试题

Qt双缓冲绘图

1. Construction of electron development environment
随机推荐
On using go language to create websocket service
Chapter 4: enable and disable im column storage for materialized view (IM 4.6)
第四章 为IM 启用填充对象之在NO INMEMORY表上指定INMEMORY列属性:示例(IM-4.4 第四部分)
Idea code formatting plug-in save actions
远程访问家里的树莓派(上)
数组---
Summary of convolution layer and pooling layer
How the database fills in IM expressions (IM 5.4)
Lesson 25 static member variables of classes
What is a gateway
Windows11 安装MySQL服务 提示:Install/Remove of the Service Denied
Idea code quality specification plug-in sonarlint
Next.js 静态数据生成以及服务端渲染的方式
Tan Xiang, CEO of Kechuang · Pera software: the essence of zero trust is digital security. To B should also deeply study the user's mind
Here comes the detailed picture and text installation tutorial of H5 game
Next. JS static data generation and server-side rendering
对称加密、证书加密
Idea database navigator plug-in
PSCP basic usage
A detailed explanation of head pose estimation [collection of good articles]