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. Item order in QAbstractItemModel and QTreeView
Forum Updated to NodeBB v4.3 + New Features

Item order in QAbstractItemModel and QTreeView

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 876 Views 1 Watching
  • 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
    rherzog
    wrote on last edited by
    #1

    Hi guys,

    how can I change the order my items the QTreeView that is backed by a custom Implementation of the QAbstractItemModel?

    Do I have to override the two methodes
    @bool QAbstractItemModel::removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() ) [virtual]@
    and
    @bool QAbstractItemModel::insertRows ( int row, int count, const QModelIndex & parent = QModelIndex() ) [virtual]@
    so that I can call "removeRow" and "insertRow" on the model?

    As far as I know I just have to alter the model apropriately and the view gets updated by the model automatically.

    kind regards for your help, reinhart

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      Take a look on "QAbstractProxyModel":http://qt-project.org/doc/qt-5/qabstractproxymodel.html and "QSortFilterProxyModel":http://qt-project.org/doc/qt-5/qsortfilterproxymodel.html

      I have not used them but from the doc it sounds like QSortFilterProxyModel is what may help you.

      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