<div dir="ltr">Ah, thanks - that explanation seems to make sense with what's happening. I'm not sure the solution I've got (calling reversed() on the list) is the *most* robust, but it works (at least for now!).<div><br></div><div>Cheers,</div><div>Chris</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 13 October 2014 20:25, Florian Bruhin <span dir="ltr"><<a href="mailto:me@the-compiler.org" target="_blank">me@the-compiler.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">* Chris Wood <<a href="mailto:c.c.wood@gmail.com">c.c.wood@gmail.com</a>> [2014-10-13 20:12:05 +0100]:<br>
> I've found that where I have a QLabel as a child of my QWidget, and a<br>
> QLabel which is a child of a QGroupBox which is a child of my QWidget, and<br>
> I toggle the visibility of all the children of the QWidget via the click<br>
> action of a button:<br>
><br>
> def toggleVis(self):<br>
> self.results = findChildren((QLabel,QGroupBox))<br>
> print self.results<br>
> for w in self.results:<br>
> w.setVisible(not w.isVisible())<br>
><br>
> After hiding the objects initially, and clicking the button again, the<br>
> QLabel which is a child of the QGroupBox does not reappear, but all 3<br>
> objects are listed when self.results is printed (full code at end of<br>
> email). I expected this to work, since findChildren is recursive.<br>
> However, it *does* work if I reverse the list (for w in<br>
> reverse(self.results)). I get the same behaviour on both Unix (Fedora 20)<br>
> and Windows 7. Is this documented? Perhaps a different way round this would<br>
> be to specify names (I could probably use some regex to ensure I capture<br>
> the objects I want), but wanted to make sure I hadn't missed something<br>
> obvious from the docs first...<br>
<br>
Hmm, shouldn't calling setVisible(True) (or show) on a widget already<br>
also show it's child widgets anways (if they never were explicitely<br>
hidden)?<br>
<br>
>From the docs to setVisible:<br>
<br>
Calling setVisible(true) or show() sets the widget to visible<br>
status if all its parent widgets up to the window are visible. If<br>
an ancestor is not visible, the widget won't become visible until<br>
all its ancestors are shown.<br>
<br>
An explicitly hidden widget will never become visible, even if all<br>
its ancestors become visible, unless you show it.<br>
<br>
It sounds to me like something like this happens:<br>
<br>
- The first item is a child of the "root"<br>
- You show it<br>
- The children get shown as well<br>
- You get to the children and because of your<br>
"setVisible(not w.isVisible()" you hide it again.<br>
<span class="HOEnZb"><font color="#888888"><br>
Florian<br>
<br>
--<br>
<a href="http://www.the-compiler.org" target="_blank">http://www.the-compiler.org</a> | <a href="mailto:me@the-compiler.org">me@the-compiler.org</a> (Mail/XMPP)<br>
GPG 0xFD55A072 | <a href="http://the-compiler.org/pubkey.asc" target="_blank">http://the-compiler.org/pubkey.asc</a><br>
I love long mails! | <a href="http://email.is-not-s.ms/" target="_blank">http://email.is-not-s.ms/</a><br>
</font></span><br>_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br></blockquote></div><br></div>