多继承自 QObject 和 QRunnable 错误 [英] multi inherit from QObject and QRunnable error
问题描述
我正在使用 pyqt4.我有一个从 QObject 和 QRunnable 继承的类,如下所示:
I'm using pyqt4. I have a class multi inherited from QObject and QRunnable like this:
class DownloadTask(QObject, QRunnable):
def __init__(self):
QObject.__init__(self)
QRunnable.__init__(self)
self.setAutoDelete(False)
DownloadTask 实例初始化时,最后一行抛出异常:
When an instance of DownloadTask is initializing, the last line throws exception:
TypeError: could not convert 'DownloadTask' to 'QRunnable'
但我认为在语法上是正确的,QRunnable 有 setAutoDelete 方法.为什么它不能转换为 QRunnable?
But I think it is correct in grammer, QRunnable has the method setAutoDelete. Why can't it convert to QRunnable?
更新:
我打算使用 QThreadPool 来管理多线程从 Internet 下载资源,并在完成后发出信号.我该怎么做?
Update:
I intend to use QThreadPool to manage multi threads downloading resources from Internet, and emit a signal after finished. How can I do that?
推荐答案
不可能定义一个新的 Python 类,该类从多个 Qt 类中分出子类.
It is not possible to define a new Python class that sub-classes from more than one Qt class.
这篇关于多继承自 QObject 和 QRunnable 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!