parent () Gets the parent object
setParent () to set the parent object
chirldren () Gets the child object (containing multiple)
findChild () to find child objects, if multiple sub-objects that meet the search criteria, the first child to find objects that meet criteria on return, that is, even if multiple child objects that meet, but only to return a child object
findChildren () to find child objects, if multiple sub-objects that meet the search criteria, all child objects in line with the conditions of return, look for the direct and indirect sub-sub-objects objects
Examples of Use
# -*- coding: utf-8 -*- from PyQt5.Qt import * obj0 = QObject() obj1 = QObject() obj2 = QObject() obj3 = QObject() obj4 = QObject() obj5 = QObject() print("obj0:" , obj0) print("obj1:" , obj1) print("obj2:" , obj2) print("obj3:" , obj3) print("obj4:" , obj4) print("obj5:" , obj5) obj1.setParent(obj0) obj2.setParent(obj0) obj3.setParent(obj1) obj4.setParent(obj2) obj5.setParent(obj2) Print (obj4.parent ()) # Returns the parent object obj2 obj4 does not return obj0 Print (obj0.children ()) # returns the sub-object obj2 and obj1 obj0, do not return to their respective child objects obj1.setParent(obj2) Print (obj1.parent ()) # returns the new parent object obj1 obj2, obj0 is not the parent object obj1.setParent (obj0) # The parent object obj1 reset to obj0 Print (obj0.findChild (QObject)) # Returns the type of sub-object QObject obj0 returns only one direct child objects found in Print (obj0.findChild (QObject, ' . 5 ' )) # Returns QObject type and objectName is obj0 5 the sub-object, the child object may also be an indirect sub-object of obj0 Print (obj0.findChild (QObject, ' 5 ' , Qt.FindDirectChildrenOnly)) # returns QObject type obj0 objectName is a child and 5, the child object only direct children obj0 of Print (obj0.findChildren (QObject)) # return QObject types of sub-objects obj0 returns all direct child objects found in