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. QTreeWidget sort problem, vs QDir::entryInfoList
Forum Update on Monday, May 27th 2025

QTreeWidget sort problem, vs QDir::entryInfoList

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 711 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.
  • O Offline
    O Offline
    opengpu2
    wrote on last edited by
    #1

    first time, i create the QTreeWidgetItem tree base on the tree struct got from traverse the Dir using QDir::entryInfoList, and the sorting in the QTreeWidget like this:
    A_dir
    a_dir
    A.txt
    B.txt
    a.txt
    b.txt

    however, when i change the tree data, and rebuild the QTreeWidget without traverse the Dir. and when i use sortItems(0, Qt::AscendingOrder), the sorting look like this:
    A.txt
    a.txt
    A_dir
    a_dir
    B.txt
    b.txt

    and i think the first one is much better, as it show all the Dir on the top, and then the files below.is there any way to sort QTreeWidget like this?
    thank you

    1 Reply Last reply
    0
    • O Offline
      O Offline
      opengpu2
      wrote on last edited by
      #2

      ps. i ues QDir::setFilter(QDir::Dirs | QDir::Files); QDir::setSorting(QDir::DirsFirst).
      that's why i got the first sorting.

      but how can i "simulate" this sorting when i didnot use QDir, but only use the QTreeWidget 's sorting?

      1 Reply Last reply
      0

      • Login

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