Results 1 to 3 of 3

Thread: browse through all the child object of a widget

  1. #1
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default browse through all the child object of a widget

    Hi,

    Is there any way to browse through all the children objects of a widget. Maybe this should be recursively...

    Any idea how to do this?

    Thanks,
    Carlos.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: browse through all the child object of a widget

    Qt Code:
    1. void BrowseChildren( QWidget * parent )
    2. {
    3. QObjectList children = parent->children();
    4. QObjectList::const_iterator it = children.begin();
    5. QObjectList::const_iterator eIt = children.end();
    6. while ( it != eIt )
    7. {
    8. QWidget * pChild = (QWidget *)(*it++);
    9. BrowseChildren( pChild );
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 

    Of course, you might want to do something with each child widget as it is discovered. Read the docs: the order of the list is determined by the stacking order of the widgets. Bringing a widget to the top of the stack by raising it changes the order.

  3. The following user says thank you to d_stranz for this useful post:

    qlands (6th July 2011)

  4. #3
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: browse through all the child object of a widget

    Excellent. Thanks.

Similar Threads

  1. Replies: 1
    Last Post: 23rd June 2011, 23:09
  2. How to save Child if Parent Object is deleted.
    By vaibhav in forum Qt Programming
    Replies: 6
    Last Post: 25th May 2011, 08:52
  3. Widget to browse file
    By nighil in forum Newbie
    Replies: 1
    Last Post: 26th January 2011, 11:01
  4. Child object not showing
    By BalaQT in forum Qt Programming
    Replies: 2
    Last Post: 24th September 2009, 14:46
  5. Replies: 9
    Last Post: 9th May 2006, 19:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.