博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
QObject: Cannot create children for a parent that is in a different thread
阅读量:6230 次
发布时间:2019-06-21

本文共 806 字,大约阅读时间需要 2 分钟。

The run() member function is executed in a different thread, rather than the thread where QNetworkRequestManager object was created.

This kind of different-thread problems happen all the time with Qt when you use multiple threads. The canonical way to solve this problem is to use signals and slots.

Create a slot in the object where QNetworkRequestManager belongs to, create a signal in ResultThread and connect both of the somewhere, the constructor of ResultThread would be a good place.

The code which is currently in ResultThread::run() goes to the new slot, and is replaced by a emit(yourSignal()). If neccessary send a pointer to your ResultThread as a parameter with your emit function to gain access to member funtions/variables.

转载于:https://www.cnblogs.com/Podevor/archive/2011/10/28/2788009.html

你可能感兴趣的文章
解析:Parallels给Mac电脑带来的好处
查看>>
skycc淘宝客推广软件 V8.2免费版
查看>>
Navicat for MySQL 11 Mac安装教程
查看>>
Navicat 如何调整栏位结构
查看>>
食品安全溯源区块链解决方案探索
查看>>
关于Spring Data JPA的save()保存,MySQL字段默认值无效
查看>>
数据结构——二叉树(PHP)
查看>>
MySQL实时性能监控工具doDBA tools
查看>>
ListView 局部刷新实现思路
查看>>
JSON笔记之在PHP语言中使用JSON
查看>>
函数的指针
查看>>
Jquery AJAX使用踩坑小记
查看>>
ubuntu下安装Apache+PHP+Mysql
查看>>
Bootstrap 过渡效果(Transition)插件
查看>>
[Linux]-Linux 命令大全
查看>>
mysql将查询到的数据导出到Excel
查看>>
Android 切换系统语言源码分析
查看>>
API 调用次数限制实现
查看>>
我的网站搭建 (第十八天) 自定义用户模型
查看>>
排序应该在数据库还是在应用程序中进行?
查看>>