[Qt-interest] Get children from layout

David Boosalis david.boosalis at gmail.com
Mon Nov 1 11:13:04 CET 2010


Thats because getChild is a method of QObject.  And it appears your layout
is not the parent, hence it has no children.  You could use
QLayout::itemAt().  I think a better solution is that when you put your
widgets in a the layout you also put them in a QList and use it for your
book keeping



On Sun, Oct 31, 2010 at 12:56 PM, Alex Ivasyuv <industral at gmail.com> wrote:

>  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,
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101101/8f255df1/attachment.html 


More information about the Qt-interest-old mailing list