I want to inherit widget1 to use its methods but I get :
"TypeError: Error when calling the metaclass bases Cannot create a
consistent method resolution order (MRO) for bases widget1, QWidget"
when I run the program. Can you explain to me why this happen?
thank.
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4 import QtCore, QtGui
import sys
class widget1(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
class widget2(QtGui.QWidget, widget1):
def __init__(self):
QtGui.QWidget.__init__(self)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
test = widget1()
test.show()
sys.exit(app.exec_())
Multiple Inheritance in PyQt4
There are multiple alternative design decisions you can use, which makes multiple QObject inheritance unnecessary.
Simple inherit from the single parent class
Composition
Make one of the classes a mixin class, which is not a QObject: