5

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
  • 235,170
  • 19
  • 170
  • 241
Tiny
  • 197
  • 7

1 Answers1

4

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
  • 4,387
  • 2
  • 33
  • 47