Multiple inheritance in PYQT, in which the inherited parent class has descendants of Qobject or Qobject

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.