Sort QObject child objects

I noticed that the QObject :: children () method returns a const reference for a QObjectList that contains qobject children. Would it be safe to drop the constant and sort the list using qSort?

Thanks Anton

+3
source share
2 answers

No, you should not do this. This is the definition of QObject :: children ():

inline const QObjectList &children() const { return d_ptr->children; }

This means that you directly get a link to an internal list of objects. And the documentation says:

Note that the order of the list changes when the QWidget Children is raised or lowered. The widget that is raised becomes the last object in the list, and the snapshot that is dropped becomes the first object in the list.

, .

+3

. ? QObjectList ?

+1

Source: https://habr.com/ru/post/1778203/


All Articles