0

我需要实现一个带有按钮和日志小部件的表单,当按下按钮时,应该在另一个线程中开始一些长时间的工作。

该过程的详细信息应回显到日志中。

不应同时启动两个作业。

我正在考虑的方式:QThread使用自己的事件循环创建子类(当然moveToThread(this)QThread的构造函数中调用),并将信号连接QButton到该线程的插槽doLongJob()

听起来不错,还是通常是错误的?其他方式:比如说,每次用户按下按钮时创建新线程。似乎更糟。

是否有一些最佳实践来做这个很常见的事情?请给我一个建议。

4

1 回答 1

0

Bard already answered in the comment, I asked him twice to write the same as an answer, but it seems he really doesn't want to.

So, I'm tired of waiting more than 7 months, and therefore have to do that myself, in order to get rid of this unanswered question.

The answer is:

You generally do not want to subclass QThread, but other than that, hooking up things with signals and slots is just fine.

于 2014-01-04T19:38:33.563 回答