0
votes

I have Qt Quick treeview connected to my QAbstractItemModel by exposing it through setContextProperty and it works well. Now I want to be able to change the order of the items (in the view and the model) by dragging them up and down. I've created DropArea

DropArea {
        anchors { fill: parent; margins: 10 }

        onEntered: {
           // ???
        }
}

but I'm not sure how to implement moving in qml. In qwidget approach it's handled by removeRows/insertRows. What's the correct approach in qt quick?

1

1 Answers

0
votes

The correct approach would be to use the model and either move items, or remove/insert them into the new location. Since those functions are not directly exposed to QML, you will have to expose them through wrapper slots, for example in your model.

When you modify the source model, the view will automatically adjust to reflect the changes.