Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Custon sorting behaviour when clicking on a Qtableview header

Custon sorting behaviour when clicking on a Qtableview header

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 433 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.
  • H Offline
    H Offline
    hachbani
    wrote on last edited by
    #1

    Hello,

    I want to implement the following behaviour:

    • the first click on a header sort the table in ascending order
    • a second click sort on same header sort it in descending order
    • a third click goes back to my default sorting (which I already implemented in lessThan() method in my Proxy method)

    I have a Qtableview, set to a QSortFilterProxyModel (subclassed) and a QAbstractTableModel (subclassed). Working on Pyside2

    I would like to implement this in my ProxyModel

    any hints on how to do that, I don't know how to get started in this.

    thanks

    JonBJ 1 Reply Last reply
    0
    • H hachbani

      Hello,

      I want to implement the following behaviour:

      • the first click on a header sort the table in ascending order
      • a second click sort on same header sort it in descending order
      • a third click goes back to my default sorting (which I already implemented in lessThan() method in my Proxy method)

      I have a Qtableview, set to a QSortFilterProxyModel (subclassed) and a QAbstractTableModel (subclassed). Working on Pyside2

      I would like to implement this in my ProxyModel

      any hints on how to do that, I don't know how to get started in this.

      thanks

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @hachbani
      Well you sound like you are almost there already! You have picked the right hierarchy.

      Since you have three states, at some level you need to note that so you know where you are, and move through them as desired from clicking. You probably want this "state flag" stored in the sub-classed QSortFilterProxyModel, so that knows what it should do about which sorting to apply. Then the UI deals with the clicks and tells the proxy model to move through the 3 states.

      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