PyQt5 QObject-对象父类、子类设置和查找
################################ # PyQt5中文网 - PyQt5全套视频教程 # # https://www.PyQt5.cn/ # # 主讲: 村长 # ################################ from PyQt5.Qt import * import sys class Window(QWidget): def __init__(self): super().__init__() self.setWindowTitle("父子关系") self.resize(600, 500) self.func_list() def func_list(self): self.func() def func(self): obj1 = QObject() print('obj1', obj1) obj2 = QObject() print('obj2', obj2) obj3 = QObject() print('obj3', obj3) obj2.setParent(obj1) obj3.setParent(obj2) print(obj2.parent()) print(obj2.children()) print(obj1.findChild(QObject)) print(obj1.findChildren(QObject)) if __name__ == '__main__': app = QApplication(sys.argv) window = Window() window.show() sys.exit(app.exec_())