How to find an object by name in pyqt?

后端 未结 2 1248
心在旅途
心在旅途 2020-12-10 14:03

I have a list of dictionaries:

globalParams = [{\'attr\':\'enabled\',\'ctrl\':\'checkBoxEnabled\',\'type\':\'checkBox\'},
                {\'attr\':\'colorMo         


        
2条回答
  •  长情又很酷
    2020-12-10 14:41

    You can use QObject::findChild method. In pyqt it should be written like this:

    checkbox = self.findChild(QtGui.QCheckBox, "checkBoxEnabled")
    

    self should be a parent widget of the checkbox.

提交回复
热议问题