how to add an element to a layout at a given index?
Unsolved
QML and Qt Quick
-
Hello, I have a ColumnLayout and I'm generating dinamically objects:
var newBlock = Qt.createComponent("Block.qml").createObject(document);
where
document
is the id of the layout.
this however creates a new object as last element of the columnlayout, but I need to create it at a given index. So I tried to move it like this:function arraymove(arr, fromIndex, toIndex) { var element = arr[fromIndex]; arr.splice(fromIndex, 1); arr.splice(toIndex, 0, element); } ... var block = Qt.createQmlObject("import QtQuick 2.15; Block {}", document); arraymove(document.children, document.children.length-1, index);
but I get this error:
TypeError: Property 'splice' of object [object Object] is not a function
and indeedtypeof document.children
returnsobject
instead of a list of Item as the docs suggest. what is the problem?thanks in advance!