PDA

View Full Version : Only get children



wirasto
24th January 2010, 17:06
I have a frame with 5 widget in it. 4 toolbutton and 1 tableview. Well, i tried get the frame children..



QList<QWidget *> anak=frame->findChildren<QWidget *>();
qDebug() << anak.size();
//result is 23


Why the result not is 5 ? How to just get only frame children, not subchildren too..

wysota
24th January 2010, 17:15
findChildren is recursive, that's why you get 23 and not 5. You can check the parentWidget() of each of the results to eliminate all indirect descendants of the widget.