先贴几篇有意思的讨论

https://www.qt.io/blog/2010/06/17/youre-doing-it-wrong#commento-login-box-container

https://www.qt.io/blog/2006/12/04/threading-without-the-headache

https://woboq.com/blog/qthread-you-were-not-doing-so-wrong.html

http://blog.debao.me/2013/08/how-to-use-qthread-in-the-right-way-part-1/

https://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/

https://blog.csdn.net/czyt1988/article/details/71194457

有篇国内:https://blog.csdn.net/lynfam/article/details/7081757

https://blog.csdn.net/bladeandmaster88/article/details/51802491

http://blog.sina.com.cn/s/blog_a6fb6cc90102vs8z.html

https://blog.csdn.net/dbzhang800/article/details/6882981

https://blog.csdn.net/dbzhang800/article/details/6889291

https://blog.csdn.net/czyt1988/article/details/64441443

https://stackoverflow.com/questions/16879971/example-of-the-right-way-to-use-qthread-in-pyqt

https://stackoverflow.com/questions/6783194/background-thread-with-qthread-in-pyqt

PYTHON:

https://stackoverflow.com/questions/20324804/how-to-use-qthread-correctly-in-pyqt-with-movetothread

So, the conclusion is:
1. Don't read Qt 4.6 docs, it is wrong as it says "To create your own threads, subclass QThread and reimplement run()." http://doc.qt.nokia.com/4.6...

  1. Don't read the given "best resource", it is also wrong, because it also subclasses QThread: "...just a small amount of work: subclass QThread and reimplement run().." http://labs.trolltech.com/b...

The correct answer is in the shortest blog given in the comments: http://labs.trolltech.com/b...
Here's a shortened snippet from it for those who don't want to dig into the tarball:

class Producer : public QObject
{
Q_OBJECT
public slots:
void produce() { ...emit produced(&data)...emit finished().. }
signals:
void produced(QByteArray *data);
void finished();
};

class Consumer : public QObject
{
Q_OBJECT
public slots:
void consume(QByteArray *data) { ...emit consumed()...emit finished().. }
signals:
void consumed();
void finished();
};

int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
// create the producer and consumer and plug them together
Producer producer;
Consumer consumer;
producer.connect(&consumer, SIGNAL(consumed()), SLOT(produce()));
consumer.connect(&producer, SIGNAL(produced(QByteArray *)), SLOT(consume(QByteArray *)));

// they both get their own thread
QThread producerThread;
producer.moveToThread(&producerThread);
QThread consumerThread;
consumer.moveToThread(&consumerThread); // start producing once the producer's thread has started
producer.connect(&producerThread, SIGNAL(started()), SLOT(produce())); // when the consumer is done, it stops its thread
consumerThread.connect(&consumer, SIGNAL(finished()), SLOT(quit()));
// when consumerThread is done, it stops the producerThread
producerThread.connect(&consumerThread, SIGNAL(finished()), SLOT(quit()));
// when producerThread is done, it quits the application
app.connect(&producerThread, SIGNAL(finished()), SLOT(quit())); // go!
producerThread.start();
consumerThread.start();
return app.exec();

}

https://nikolak.com/pyqt-threading-tutorial/

https://blog.csdn.net/weixin_34348805/article/details/90525817

https://yq.aliyun.com/articles/119876?scm=20140722.184.2.173

PyQt中QThread多线程的正确用法【待完善】的更多相关文章

  1. 转载~kxcfzyk:Linux C语言多线程库Pthread中条件变量的的正确用法逐步详解

    Linux C语言多线程库Pthread中条件变量的的正确用法逐步详解   多线程c语言linuxsemaphore条件变量 (本文的读者定位是了解Pthread常用多线程API和Pthread互斥锁 ...

  2. Spring MVC中Session的正确用法<转>

    Spring MVC是个非常优秀的框架,其优秀之处继承自Spring本身依赖注入(Dependency Injection)的强大的模块化和可配置性,其设计处处透露着易用性.可复用性与易集成性.优良的 ...

  3. C#中dynamic的正确用法

    C#中dynamic的正确用法  http://www.cnblogs.com/qiuweiguo/archive/2011/08/03/2125982.html dynamic是FrameWork4 ...

  4. 【转】Spring MVC中Session的正确用法之我见

    Spring MVC是个非常优秀的框架,其优秀之处继承自Spring本身依赖注入(Dependency Injection)的强大的模块化和可配置性,其设计处处透露着易用性.可复用性与易集成性.优良的 ...

  5. C#中dynamic的正确用法 以及 typeof(DynamicSample).GetMethod("Add");

    dynamic是FrameWork4.0的新特性.dynamic的出现让C#具有了弱语言类型的特性.编译器在编译的时候不再对类型进行检查,编译期默认dynamic对象支持你想要的任何特性.比如,即使你 ...

  6. 【转】改善C#程序的建议2:C#中dynamic的正确用法 空间

    dynamic是FrameWork4.0的新特性.dynamic的出现让C#具有了弱语言类型的特性.编译器在编译的时候不再对类型进行检查,编译期默认dynamic对象支持你想要的任何特性.比如,即使你 ...

  7. C#中dynamic、ExpandoObject 的正确用法

    原文地址:http://www.cnblogs.com/qiuweiguo/archive/2011/08/03/2125982.html dynamic是FrameWork4.0的新特性.dynam ...

  8. C#中dynamic的正确用法【转】

    dynamic是FrameWork4.0的新特性.dynamic的出现让C#具有了弱语言类型的特性.编译器在编译的时候不再对类型进行检查,编译期默认dynamic对象支持你想要的任何特性.比如,即使你 ...

  9. Spring MVC中Session的正确用法之我见

    Spring MVC是个非常优秀的框架,其优秀之处继承自Spring本身依赖注入(Dependency Injection)的强大的模块化和可配置性,其设计处处透露着易用性.可复用性与易集成性.优良的 ...

随机推荐

  1. 论文阅读:Reducing Transformer Depth On Demand With Structured Dropout

    Introduction 这篇paper是做Transformer压缩的,但其实bert的核心也就是transformer,这篇paper的实验里也做了bert的压缩.作者的主要工作是提出了Layer ...

  2. 201771010128王玉兰《面向对象程序设计(Java)》第十三周学习总结

    第一部分:基础理论知识 1.事件处理基础 事件源(event source):能够产生事件的对象都可 以成为事件源,如文本框.按钮等.一个事件源是一个 能够注册监听器并向监听器发送事件对象的对象. 事 ...

  3. 201771010128 王玉兰《面象对象程序设计 (Java) 》第六周学习总结

    ---恢复内容开始--- 第一部分:基础知识总结: 1.继承 A:用已有类来构建新类的一种机制,当定义了一个新类继承一个类时,这个新类就继承了这个类的方法和域以适应新的情况: B:特点:具有层次结构. ...

  4. Windows下搭建RabbitMQ环境

    1.下载安装Erlang 下载地址:https://www.erlang.org/downloads 下载之后,正常安装即可. 安装完毕之后,开始栏里会有个这图标: 2.下载安装RabbitMQ 下载 ...

  5. Python 绘制全球疫情地图

    国内疫情得到控制后,我就没怎么再关心过疫情,最近看到一条新闻,全球疫情累计确诊人数已经突破 500w 大关,看到这个数字我还是有点吃惊的. 思来想去,还是写一篇全球疫情的分析的文章,本文包括网络爬虫. ...

  6. axios发送post form请求

    axios发送post form请求 只需修改url和data即可 axios({ url: '/user', method: 'post', data: { firstName: 'Fred', l ...

  7. MySQL8离线安装

    现在离线安装包: 登录官网准备下载 https://dev.mysql.com/downloads/mysql/ 2,开始下载 解压安装包: 开始解压: 解压完成: 新建init文件: 在解压目录下创 ...

  8. 关于vue+element对ie9的兼容el-upload不支持在IE9上传

    关于vue+element对ie9的兼容el-upload不支持在IE9上传 https://lian-yue.github.io/vue-upload-component/#/zh-cn/ 解决方案 ...

  9. 非阻塞赋值(Non-blocking Assignment)是个伪需求(2)

    https://mp.weixin.qq.com/s/5NWvdK3T2X4dtyRqtNrBbg   13hope: 个人理解,Verilog本身只是“建模”语言.具体到阻塞/非阻塞,只规定了两种赋 ...

  10. rewrite和return的简单需求

    Rewrite 需求作业 背景:现在我有一个网站,www.linux.com www.linux.com访问主页面 friend.linux.com访问交友页面 blog.linux.com访问博客页 ...