Unsolved Does QML TreeView support signal layoutChanged emitted from model?
-
I have a model that works well with QTreeView. In the model I implemented a sort that looks like this:
void SimpleTreeModel::sort(Node* sortedNode) { emit layoutAboutToBeChanged(QList<QPersistentModelIndex>(), VerticalSortHint); QModelIndexList oldIndices = persistentIndexList(); Node::SortType sortType = Node::Down; //sort starting node sortedNode->sortChildren(sortType); QModelIndexList newIndices; newIndices.reserve(oldIndices.size()); for(const auto &i : oldIndices) { Node* node = const_cast<Node*>(nodeFromIndex(i)); QModelIndex index = indexFromNode(node); newIndices.push_back(index); } changePersistentIndexList(oldIndices, newIndices); QModelIndex startingIndex = indexFromNode(sortedNode); emit layoutChanged({ QPersistentModelIndex(startingIndex) }, VerticalSortHint); }
when I call this function, QTreeView updates the view, but TreeView in QML don't do this. QML TreeView usage:
TreeView { model: treeModel TableViewColumn { title: "Title" role: "title" width: 700 } }
What am I doing wrong? Why the view does not update the layout of the elements after sorting?