Item order in QAbstractItemModel and QTreeView



  • 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



  • 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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.