c++ side -------------------------------------------- bool DataModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) { if (areIndexesSame(sourceParent, destinationParent)) { if (sourceRow == destinationChild) { qDebug() << "sourceRow == destinationChild in case when parent is same @" << Q_FUNC_INFO; return true; } if (sourceRow < destinationChild) { beginMoveRows(sourceParent, sourceRow, sourceRow + count - 1, sourceParent, destinationChild + count); } else { beginMoveRows(sourceParent, sourceRow, sourceRow + count - 1, sourceParent, destinationChild); } } else { beginMoveRows(sourceParent, sourceRow, sourceRow + count - 1, destinationParent, destinationChild + 1); } // checking offspring const QModelIndex & sourceIndex = index(sourceRow, 0, sourceParent); const QModelIndex & destinationIndex = index(destinationChild, 0, destinationParent); bool ok = checkIfOffspring(destinationIndex, sourceIndex); if (ok) { qDebug() << " destination is parent of source " << Q_FUNC_INFO; return false; } const PersistantStorageSyncWorker * worker = getPersistantStorageWorker(); ok = worker->moveRows(sourceParent, sourceRow, count, destinationParent, destinationChild); if (!ok) return false; QAbstractItemModel::endMoveRows(); //beginResetModel(); //FIXME because of bug https://bugreports.qt.io/browse/QTBUG-55864 I have to resetModel to update indexes in treeview. //endResetModel(); //TODO check if it is fixed as this bug was closed return true; } --------------------------- QML side where I initiate move actually --------------------------- //where indx is bind to styleData.index (here is the bug probably) Rectangle { id: moveTaskButton anchors.left: parent.left anchors.bottom: parent.bottom height: editor.height * 0.3 width: height visible: open border.width: 1 * dp Text { id: textOfMoveTaskButton anchors.centerIn: parent text: treeModel.isSourceSet() ? "paste" : "move" font.pointSize: moveTaskButton.height * 0.5 > 1 ? moveTaskButton.height * 0.15 : 1 onVisibleChanged: { text = treeModel.isSourceSet() ? "paste" : "move" } } MouseArea { anchors.fill: parent onClicked: { if (treeModel.isSourceSet()) { treeModel.setTargetToMove(indx) textOfMoveTaskButton.text = "move" //open = false } else { treeModel.setSourceToMove(indx) textOfMoveTaskButton.text = "paste" } } } }