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. how can i sort by myself when i click the header? on QTreeWidget
Forum Update on Monday, May 27th 2025

how can i sort by myself when i click the header? on QTreeWidget

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 654 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

    when i setSortingEnabled(true), i can click the header, and it will sort ascending or descengding, but it's just sort by the name, and do not care anything else.
    how can i sort by myself when i click the header?
    i want to sort by the name on basis of the item type(eg, dir, and files).
    thank you

    p3c0P 1 Reply Last reply
    0
    • O opengpu2

      when i setSortingEnabled(true), i can click the header, and it will sort ascending or descengding, but it's just sort by the name, and do not care anything else.
      how can i sort by myself when i click the header?
      i want to sort by the name on basis of the item type(eg, dir, and files).
      thank you

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @opengpu2 You can subclass QTreeWidgetItem and create your own item. Then re-implement operator< and return true or false depending upon your conditions.

      157

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

        is there any demos?
        should i re-implement operator< , operator>....and anything else?

        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