Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Incorrect order on QTreeView with QFileSystemModel
Forum Update on Monday, May 27th 2025

Incorrect order on QTreeView with QFileSystemModel

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 187 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vectrom
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vectrom
      wrote on last edited by
      #2

      Ok, I've resolved it by change:

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

      to

      pFileSystemModel->setRootPath("");
      
      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved