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. QTableView model that allows appending and sorting?
QtWS25 Last Chance

QTableView model that allows appending and sorting?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 185 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I have been using QStandardItemModel with a QTableView, this enables me to append content to the table. Now I would like to implement sortable columns so I'm looking at QSortFilterProxyModel however it isn't quite the same in that it doesn't appear to have an append function.

    Is there another way or another model that supports both that I should be using?

    Kind Regards,
    Sy

    SPlattenS 1 Reply Last reply
    0
    • SPlattenS SPlatten

      I have been using QStandardItemModel with a QTableView, this enables me to append content to the table. Now I would like to implement sortable columns so I'm looking at QSortFilterProxyModel however it isn't quite the same in that it doesn't appear to have an append function.

      Is there another way or another model that supports both that I should be using?

      SPlattenS Offline
      SPlattenS Offline
      SPlatten
      wrote on last edited by SPlatten
      #2

      I think the solution is to call setSourceModel and pass it an instance of QStandardItemModel, I also had to call setSortingEnabled(true);

      Kind Regards,
      Sy

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        A proxy model is put between a view and another model. It does not provide any API to modify the source model as it is not its role.

        You still interact with your original model for everything that is related to adding removing rows, columns, etc.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

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