Can not reorder QObject children
Hi, I am deriving in-app data from QObject so I can take advantage stuff like RTTI, parent/child relationship, etc. But I need to have non-const access to a QObjects child list - primarily to change the position of a child object in the list (similar to what QWidget does). Any thoughts on how I can do this?
To reorder children, you can:
- Get all children list;
- Set parent to null one by one;
- Reorder them;
- Set parent to original parent one by one.
Hi and welcome to devnet,
Out of curiosity, why do you need to fiddle with the order of the children of a QObject object ?
@SGaist basically for the same reason as QWidget - to maintain a Z-Order.
@jiancaiyang interesting - this may work :)