Rearranging Items contained in GridLayout?
Is there some recommended way how to achieve the following?
I do use GridLayout populated with Items (in fact interpreting language icons dynamically created from C++), which are arranged based on :
- columns count (to automatically wrap long rows)
- multiple rows (to allow programmer to split "code" into logical sections.
Now I need to insert new command not at the end of last row, but right before (or after if it would get easier) other (user selected) icon. I have pointer to the icon Item ready, however I did not find any API functionality to rearrange Items in GridLayout. (After some googling I understood (maybee wrong), that stackBefore() just rearranges Z-order, but not the order Items are displayed inside GridLayout.)
In several posts recommended strategy "remove all Items and add them all into GridLayout again in the newly requested order" seems a bit stone age to me and I will use it as fall back strategy, but not before I will get confirmation here that there is no more sophisticated alternative in QML API.
GridLayout doesnot have any insert methods. Instead if you use GridView, you can provide a C++/QML model where you can insert Items at any particular location.
Thanks for advice. I did not dig into QML model/view API yet, but will do as this my project is partly intended as hands on training for Qt. Will come back with my experience/solution once I get so far.
Ok. Take your time and Happy Coding! :)