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. TreeView
Qt 6.11 is out! See what's new in the release blog

TreeView

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 388 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.
  • R Offline
    R Offline
    rssweiss
    wrote on last edited by
    #1

    Hi,

    I have a TreeView of files, as follows:

    folder_path:
    -> file_1.txt
    -> file_2.txt
    -> file_10.txt
    -> file_20.txt
    

    When I run the application of Qt from a docker container, it somewhat reads the files in a different order, and shows them in the TreeView as:

    folder_path:
    -> file_1.txt
    -> file_10.txt
    -> file_2.txt
    -> file_20.txt
    

    Because 1 comes before 2. It's sorting it alphabetically, not arithmetically.

    How do I sort the files in the model?

    Thanks

    Christian EhrlicherC 1 Reply Last reply
    0
    • R rssweiss

      Hi,

      I have a TreeView of files, as follows:

      folder_path:
      -> file_1.txt
      -> file_2.txt
      -> file_10.txt
      -> file_20.txt
      

      When I run the application of Qt from a docker container, it somewhat reads the files in a different order, and shows them in the TreeView as:

      folder_path:
      -> file_1.txt
      -> file_10.txt
      -> file_2.txt
      -> file_20.txt
      

      Because 1 comes before 2. It's sorting it alphabetically, not arithmetically.

      How do I sort the files in the model?

      Thanks

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @rssweiss said in TreeView:

      How do I sort the files in the model?

      Use a QSortFilterProxyModel.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      R 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        @rssweiss said in TreeView:

        How do I sort the files in the model?

        Use a QSortFilterProxyModel.

        R Offline
        R Offline
        rssweiss
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thank you Chrisitan! I will look at it.
        thanks

        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