moveToThread的根本目的还是为了处理QObject的事件循环(如果为空指针的话,当前对象的所有的事件都不处理了),看官方说明就知道了
2023-09-11 14:19:08 时间
Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the targetThread.
To move an object to the main thread, use QApplication::instance() to retrieve a pointer to the current application, and then use QApplication::thread() to retrieve the thread in which the application lives. For example:
myObject->moveToThread(QApplication::instance()->thread());
http://doc.qt.io/archives/qt-4.8/qobject.html#moveToThread
相关文章
- [转] JavaScript:彻底理解同步、异步和事件循环(Event Loop)
- 事件循环与线程 二
- Qt-事件循环概念及循环函数详解
- QT消息/事件循环机制与多线程的关系
- Jquery 事件冒泡、元素的默认行为的阻止、获取事件类型、触发事件
- 《Node学习指南》一1.3 异步函数及Node事件循环
- QThread::wait(),一直以来我以为它阻塞的是QThread对象,可是我现在明白,原来阻塞的是这个对象所在的线程(通常是主线程)——所有事情源于 QThread 的事件循环——如果使用继承QThread这一方法,QThread::quit()没有效果,因为这个线程根本就不需要事件循环
- Qt状态机框架(状态机就开始异步的运行了,也就是说,它成为了我们应用程序事件循环的一部分了)
- JS事件属性总结【鼠标 / 键盘 / 表单】
- 浏览器工作原理:浅析页面循环系统 - 消息队列与事件循环 - 页面是怎么“活”起来的
- 不刷新网页修改url链接(history.pushState和history.replaceState新增、替换历史记录用法介绍)、popstate玩转浏览器历史记录介绍、如何触发popstate事件、popstate事件的应用场景、history.state查看当前页面数据介绍
- Node.js:创建应用+回调函数(阻塞/非阻塞)+事件循环
- 【Unity3D日常开发】Unity循环里面给按钮添加绑定事件
- Unity 基础 之 简单实现鼠标点击(手机触屏)非 UI 处监听双击事件/长按事件的功能(内附判断点击在UI上还是非UI上的方法)
- 深入理解JavaScript的闭包特性如何给循环中的对象添加事件
- C# winform中的事件传递过程中忽略部分事件消息