我正在尝试为接口(interface)创建一个抽象基类,但我需要它从 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
有什么想法吗?
谢谢
请您参考如下方法:
基于 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
