![](/img/trans.png)
[英]Python type annotations for instance of class derived from abstract base class
[英]How to create an abstract base class in python which derived from QObject
我正在尝试为接口创建一个抽象基类,但我需要它从 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
有任何想法吗?
谢谢
基于多继承元类冲突
尝试
import abc
from PyQt5.QtCore import QObject, pyqtWrapperType
class FinalMeta(pyqtWrapperType, abc.ABCMeta):
pass
class interface_class(QObject, metaclass=FinalMeta):
pass
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.