当前位置:网站首页>Qt线程与界面
Qt线程与界面
2022-06-10 23:33:00 【雨田嘟嘟】
看了个开源库Stacer,里面使用到了QConcrrent,这个使用很方便,这里简单记录一下总结下Qt的线程创建方法。
Qt线程创建方法
- QThread继承
- QObject moveToThread
- QConcurrent::run
Qt中提到线程那么不得不说一下线程和界面组件的关系。
线程与界面组件
- 在QT中,所有界面组件相关的操作都必须在主线程中(也就是GUI thread),在Qt程序线程中不能直接创建QWidget之类的界面组件,也不能直接操作界面组件.
QThread线程如何操作界面组件
方法1
绑定线程对象的信号和UI对象的槽,线程中发送emit信号。
方法2
继承QEvent类,使用QApplication::postEvent()实现向界面发送事件
方法3
直接使用Invokes()函数来调用界面组件对象的信号槽 ,(可用来调用UI对象的私有信号或槽):
边栏推荐
- 项目连接不到远程虚拟机The driver has not received any packets from the server.
- SQL query, subquery as result field
- Static method static learning
- Mysql database table backup
- array_column() expects parameter 1 to be array, array given
- 集线器、交换机与路由器有什么区别?
- [network planning] 1.5 seven layer network model and five layer network model
- twelve billion three hundred and twenty-four million two hundred and forty-three thousand two hundred and forty-two
- The principle and source code interpretation of executor thread pool in concurrent programming
- Philips coo will be assigned to solve the dual crisis of "supply chain and product recall" in the face of crisis due to personnel change
猜你喜欢

With a market value of 21.5 billion yuan, will the post-80s generation in Sichuan make TV history?
![[JVM] garbage collection mechanism](/img/61/e7611380954cdcd316dd0e570bdf17.png)
[JVM] garbage collection mechanism

阻塞隊列 — DelayedWorkQueue源碼分析

Wechat applet to realize OCR scanning recognition

Download Google gcr IO image

浅谈有赞搜索质量保障体系 v2021

Signature verification failed during system application installation

字符串时间排序,对时间格式字符串进行排序

MESI cache consistency protocol for concurrent programming

阻塞队列 — DelayedWorkQueue源码分析
随机推荐
Multipass Chinese document - instructions for use (contents page)
SQL query, subquery as result field
How to install mathtype6.9 and related problem solutions in office2016 (word2016)
数的奥秘之幂数与完全平方数
Static method static learning
Mysql database table backup
浅谈有赞搜索质量保障体系 v2021
Volatile keyword for concurrent programming
Deploy netron services through kubernetes and specify model files at startup
Detailed decomposition of the shortest path problem in Figure
SQL statement -- enter the month, query the date (month, year, day), and output the month
Multipass中文文档-教程
ts+fetch实现选择文件上传
Safety training management measures
How word removes the header line
富文本活动测试1
SLAM卡尔曼滤波&&非线性优化
BGP basic concept and iBGP basic configuration
With a market value of 21.5 billion yuan, will the post-80s generation in Sichuan make TV history?
项目连接不到远程虚拟机The driver has not received any packets from the server.