<div dir="ltr"><div>I've found that where I have a QLabel as a child of my QWidget, and a QLabel which is a child of a QGroupBox which is a child of my QWidget, and I toggle the visibility of all the children of the QWidget via the click action of a button:</div><div><br></div><div>def toggleVis(self):</div><div>  self.results = findChildren((QLabel,QGroupBox))</div><div>  print self.results</div><div>  for w in self.results:</div><div>    w.setVisible(not w.isVisible())</div><div><br></div><div>After hiding the objects initially, and clicking the button again, the QLabel which is a child of the QGroupBox does not reappear, but all 3 objects are listed when self.results is printed (full code at end of email).  I expected this to work, since findChildren is recursive.  However, it *does* work if I reverse the list (for w in reverse(self.results)).  I get the same behaviour on both Unix (Fedora 20) and Windows 7. Is this documented? Perhaps a different way round this would be to specify names (I could probably use some regex to ensure I capture the objects I want), but wanted to make sure I hadn't missed something obvious from the docs first...</div><div><br></div><div>Cheers,</div><div>Chris</div><div><br></div><div>------</div><div><br></div><div><div>import sys</div><div>from PyQt4 import QtGui, QtCore</div><div><br></div><div>class Example(QtGui.QWidget):</div><div>    </div><div>    def __init__(self):</div><div>        super(Example, self).__init__()</div><div>        vbox = QtGui.QVBoxLayout()</div><div>        gb = QtGui.QGroupBox()</div><div>        </div><div>        button = QtGui.QPushButton("Hide")</div><div>        button.clicked.connect(self.toggle)</div><div><br></div><div>        vbox.addWidget(button)</div><div>        </div><div>        lbl = QtGui.QLabel("Test Label")</div><div>        vbox.addWidget(lbl)</div><div><br></div><div>        gbLayout = QtGui.QFormLayout()</div><div>        lbl1 = QtGui.QLabel("Hello", gb)</div><div>        gbLayout.addWidget(lbl1)</div><div>    </div><div>        le1 = QtGui.QLineEdit(gb)</div><div>        gbLayout.addWidget(le1)</div><div>    </div><div>        gb.setLayout(gbLayout)</div><div>        vbox.addWidget(gb)</div><div><br></div><div>        gb.setTitle("Test")</div><div>        self.setLayout(vbox)    </div><div>        </div><div>        self.show()</div><div>   </div><div>    def toggle(self):</div><div><br></div><div>       self.l = self.findChildren((QtGui.QGroupBox, QtGui.QLabel))</div><div>       print self.l</div><div>       for i in self.l:</div><div>         i.setVisible(not i.isVisible())</div><div><br></div><div>if __name__ == '__main__':</div><div>    app = QtGui.QApplication(sys.argv)</div><div>    ex = Example()</div><div>    sys.exit(app.exec_())</div></div><div><br></div></div>