Results 1 to 2 of 2

Thread: Only get children

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Only get children

    I have a frame with 5 widget in it. 4 toolbutton and 1 tableview. Well, i tried get the frame children..

    Qt Code:
    1. QList<QWidget *> anak=frame->findChildren<QWidget *>();
    2. qDebug() << anak.size();
    3. //result is 23
    To copy to clipboard, switch view to plain text mode 

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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Only get children

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. StyleSheets and children
    By spraff in forum Qt Programming
    Replies: 2
    Last Post: 26th November 2008, 19:00
  2. Replies: 3
    Last Post: 8th September 2008, 18:18
  3. creating different types of mdi children
    By OriginalCopy in forum Qt Programming
    Replies: 2
    Last Post: 10th March 2008, 16:51
  4. How do I get the children of a layout?
    By ksierens in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2008, 14:57
  5. children()
    By vermarajeev in forum Qt Programming
    Replies: 2
    Last Post: 14th May 2007, 15:15

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.