Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Sort by Clicking on Column Headers in QML TableView
QtWS25 Last Chance

Sort by Clicking on Column Headers in QML TableView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlqtableviewc++
1 Posts 1 Posters 548 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.
  • F Offline
    F Offline
    Futster
    wrote on 5 Oct 2021, 23:28 last edited by
    #1

    I am trying to create a table in QML, connected to a model, which allows sorting asc/desc by clicking on the column header. I have created a TableView in QML, connected to QSortFilterProxyModel, connected to QAbstractTableModel, and so far so good. But I'm stuck on how to add sorting by clicking on column headers in QML.

    In the documentation for QSortFilterProxyModel, it says that in order to sort the contents of the accompanying view, you have to set the sortingEnabled property in the accompanying QTableView (could be a QListView, QTableView, or QTreeView) to true using setSortingEnabled(bool enable). Enabling this property seems to magically add click to sort capabilities to the columns...in C++'s QTableView.

    However, I'm working in QML. How can I achieve the same for my QML TableView? I thought about subclassing the QTableView and exposing it to QML but that seems like a lot of work for something which is probably already available somehow.

    1 Reply Last reply
    0

    1/1

    5 Oct 2021, 23:28

    • Login

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