当前位置:网站首页>Qt刷新UI界面问题
Qt刷新UI界面问题
2022-07-28 14:29:00 【飞天_】
当执行完settext()操作之后,如果后面死循环或者很占用主线程时间的处理,那么界面就不会立刻更新,只会等到逻辑处理完之后才会更新界面,那么有什么办法可以立刻更新界面呢?
第一种:将很占用主线程资源的操作放在另外一个线程中执行,这样就不会影响主线程的界面更新操作
第二种:执行settext()之后直接执行一次qApp->processEvent()这样就能做到立刻更新界面了
需要说下的是更新界面都是等到执行a. exec()之后才能更新,而在a. exec()中实际上执行的也是processEvent()函数
Ui的更新只能是在主线程中更新
虽然更新界面都是等到逻辑执行完以后,执行了a. exec()之后才会更新界面,但是有一个控件比较特殊会立刻更新界面,那就是进度条控件QProcessBar 中的setvalue()函数,这个是会立刻更新界面的,而且如果setvalue()之前有更新其他控件的操作,也是可以立刻更新界面的,估计进度条的setvalue()中也是执行了qApp->processEvent()才能做到立刻更新界面
边栏推荐
- Write a standard character device driver with your hands
- MIT指出公开预训练模型不能乱用
- crmeb标准版附带的客服系统
- Jy-7ga/1 voltage relay
- Jds-12 time relay
- Publish raspberry pie web page with cpolar (apache2 installation test)
- Apple iPhone app icon hidden how to retrieve and restore the hidden app icon displayed on the iPhone iPhone desktop to the iPhone iPhone iPhone desktop?
- Configure CX Oracle solution (cx_oracle.databaseerror) dpi-1047: cannot locate a 64 bit Oracle client library: "th
- Srtt-110vdc-4h-c time relay
- 全开源免费的客服系统来了
猜你喜欢

Apple iPhone app icon hidden how to retrieve and restore the hidden app icon displayed on the iPhone iPhone desktop to the iPhone iPhone iPhone desktop?

Shellcode writing learning environment

Idea debugging burpsuit plug-in

sql语句的执行流程

Chrome plug-in debugging

Jogy-61 voltage relay

ArcGIS Pro 中的编辑器

Ry-d1/1 voltage relay

7/13 (pond sampling)

Execution process of SQL statement
随机推荐
.net core version 2.2 cross domain configuration
电压继电器DY-28C
Installing CONDA and configuring Jupiter
解决pycharm使用powershell出错问题
.net core 2.2 版本跨域配置
4518. Minimum ticket price
Understanding of entropy and cross entropy loss function
Voltage relay dy-28c
Pytorch - autograd automatic differentiation
Jds-12 time relay
crmeb v4.3部署流程
[jspwiki]jspwiki installation deployment and configuration
Classic Dijkstra and the longest way
3511. Water pouring problem
MPLS LDP的原理与配置
ArcGIS Pro 中的编辑器
Idea debugging burpsuit plug-in
代码比较干净的多商户商城系统
DAY:7/11
Establish binary tree + C language code from preorder and middle order