4

I'm trying to create an abstract base class for an interface, but I need it to derive from QObject for signals and slots. My class definition looks like this:

import abc
from PyQt5.QtCore import QObject

class interface_class(abc.ABC, QObject):
    pass

It fails with:

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

Any ideas?

thanks

eyllanesc
  • 221,139
  • 17
  • 121
  • 189
Tiny
  • 187
  • 7

1 Answers1

3

Based on Multiple inheritance metaclass conflict

Try

import abc
from PyQt5.QtCore import QObject, pyqtWrapperType

class FinalMeta(pyqtWrapperType, abc.ABCMeta):
    pass

class interface_class(QObject, metaclass=FinalMeta):
    pass
shao.lo
  • 3,948
  • 2
  • 29
  • 41