multi inherit from QObject and QRunnable error

ぐ巨炮叔叔 提交于 2021-02-05 06:10:35

问题


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)

When an instance of DownloadTask is initializing, the last line throws exception:

TypeError: could not convert 'DownloadTask' to 'QRunnable'

But I think it is correct in grammer, QRunnable has the method setAutoDelete. Why can't it convert to QRunnable?

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?


回答1:


PyQt reference guide > Things to be Aware Of > Multiple inheritance:

It is not possible to define a new Python class that sub-classes from more than one Qt class.



来源:https://stackoverflow.com/questions/15134640/multi-inherit-from-qobject-and-qrunnable-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!