views:

45

answers:

2

Hi,

I try to hide all widgets in layout. But looks like findChildren doesn't work for layout.

Here's my sample code:

     QLayout * layout = widget -> findChild<QLayout *> (layoutName);
     QList<QWidget *> list = layout -> findChildren<QWidget *> ();

     cout << list.size() << endl;

size is 0, but inside this layout I have a few widgets. But the same code works fine if I try to get widgets from parent widget.

How I can get them from appropriate layout?

Thanks,

A: 

Did you try children() method instead of findChildren() ? Maybe you are getting a 'bad' layout from widget -> findChild<QLayout *> (layoutName) method. Try to find children right after creating the layout - so you are sure the layout is correct. Doing so you will be able do determine what function works wrong.

Andrew
Yes I tried children(), without any luck. I can't check after creation, as this is loaded from .ui... For widgets works fine... Issue only with layout..
Alex Ivasyuv