PDA

View Full Version : findChildren and sorting



ravas
17th December 2015, 03:57
1. How is the list returned by findChildren<QDockWidget*>() sorted?

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

prasad_N
17th December 2015, 08:17
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.

anda_skoa
17th December 2015, 08:39
1. How is the list returned by findChildren<QDockWidget*>() sorted?

Probably by parent and in the same parent by order of being parented.



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,
_

ravas
17th December 2015, 19:37
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.