Results 1 to 4 of 4

Thread: findChildren and sorting

  1. #1
    Join Date
    Jun 2015
    Location
    California, USA
    Posts
    61
    Thanks
    43
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default findChildren and sorting

    1. How is the list returned by findChildren<QDockWidget*>() sorted?

    2. How would you sort the list by window title?

  2. #2
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: findChildren and sorting

    1. Not sure about the order of find children
    2. I don't think so there is a ready made way to sort by title in Qt
    sorting can be achieved by QMap some thing like QMap<QString, QWidget>
    where key is window title & value is your widget then they will get stored & sorted by window title.
    Thanks :-)

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

    ravas (17th December 2015)

  4. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: findChildren and sorting

    Quote Originally Posted by ravas View Post
    1. How is the list returned by findChildren<QDockWidget*>() sorted?
    
    Probably by parent and in the same parent by order of being parented.

    Quote Originally Posted by ravas View Post
    2. How would you sort the list by window title?
    Using a sort algorithm (e.g. qsort or std::sort) with a lessThan predicate that compares the window titles.

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    ravas (17th December 2015)

  6. #4
    Join Date
    Jun 2015
    Location
    California, USA
    Posts
    61
    Thanks
    43
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11

    Default Re: findChildren and sorting

    Quote Originally Posted by anda_skoa View Post

    Probably by parent and in the same parent by order of being parented.
    That's what I would have expected, and it seems that way for toolbars;
    however, I can't make sense of the order for dockwidgets.

Similar Threads

  1. QWidget findChildren shows non existing childs
    By Goodwin in forum Qt Programming
    Replies: 4
    Last Post: 2nd September 2015, 20:37
  2. QObject::findChildren() strange behavior
    By folibis in forum Qt Programming
    Replies: 3
    Last Post: 2nd December 2013, 09:06
  3. Replies: 2
    Last Post: 25th November 2011, 01:47
  4. findChildren<QwtPlot *>()
    By gib in forum Qwt
    Replies: 0
    Last Post: 23rd March 2010, 04:09
  5. QObject::findChildren
    By TheKedge in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2006, 11:34

Tags for this Thread

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.