If child multiple Inheritance (parent_1,parent_2,parent_3), its super function
Super (Child, self). __init__ ()
The leftmost parent of the inheritance is executed: parent_1.__init__ ()
But if Parent_2 is a descendant of Qobject or Qobject,
Execute qobject.__init__ (self) in __init__ () in child
Will cause parent_3.__init__ (self) to be executed
The reason is unknown ...
Example Kazakhstan:
from pyqt5.qtcore import qobjectclass parent_1:def __init__ (self): Prin T (' parent_1.__init__ ') class Parent_2 (parent_1): def __init__ (self): Super (Parent_2, self). __init__ () Print (' parent_2.__init__ ') class Parent_3:def __init__ (self): print (' parent_3.__init__ ') class Child_2 (Qobject, parent_2,parent_3): Def __init__ (self): #QObject. __init__ (self) Span style= "Background-color: #ff0000;" >super (Qobject, self). __init__ () #super (child_2, self). __init__ () if __name__ = = ' __ main__ ': Import sys from pyqt5.qtwidgets import qapplication app = Qapplication (SYS.ARGV) #################### ################################# print ('---------------------------') child_2 = Child_2 () ######### ############################################ Sys.exit (App.exec_ ())
The output is:
Multiple inheritance in PYQT, in which the inherited parent class has descendants of Qobject or Qobject