QTreeView with QFileSystemModel not sorting
I have a
QFileSystemModelin which I only keep the
I have set
m_dirTree->setSortingEnabled(true); m_dirTree->sortByColumn(index.column(), Qt::AscendingOrder);
and use the following to add a subfolder to the currently selected folder:
index = m_treeModel->mkdir(index, foldername);
The view is updated to show the newly added folder, but it is appended at the end of the subdir list. So even if I name my new folder AA, it will still show after ZZZ.
Forcing a sort by clicking on the header's sort arrow does not correct this either?
What is going on?
Thanks @VRonin .
I tried you connect, and the slot is called, but the sort has no effect.
The thing is, when I create the AA folder manually in Explorer, the tree updates correctly and shows AA at the top. So maybe I should try using another method to make the directory than
Indeed, when I use
QDir::mkdirI()the model updates to the correct sort order...