Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Incorrect order on QTreeView with QFileSystemModel



  • Hello. I have QTreeView with QFileSystemModel. Files and directories on tree are in alphabetical order by default. If I open file/directory from directory not opened or not expanded before and select element on tree by setCurrentIndex(), that file is first on tree (of course in correct directory). The problem exists on Windows, on MacOS everything is OK.

    Example:
    0_1565004698230_changedOrderSDViewer.PNG



  • Ok, I've resolved it by change:

    pFileSystemModel->setRootPath(QDir::rootPath());
    

    to

    pFileSystemModel->setRootPath("");
    

Log in to reply