我试图为接口创建一个抽象基类,但我需要它从QObject派生信号和插槽。我的班级定义如下:
import abc
from PyQt5.QtCore import QObject
class interface_class(abc.ABC, QObject):
pass
失败了:
TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
有什么想法吗?
感谢
答案 0 :(得分:2)
基于Multiple inheritance metaclass conflict
尝试
import abc
from PyQt5.QtCore import QObject, pyqtWrapperType
class FinalMeta(pyqtWrapperType, abc.ABCMeta):
pass
class interface_class(QObject, metaclass=FinalMeta):
pass