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. QTreeView: Inserting row to model breaks sorting (QSortFilterProxyModel).
Forum Updated to NodeBB v4.3 + New Features

QTreeView: Inserting row to model breaks sorting (QSortFilterProxyModel).

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 4.1k 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.
  • S Offline
    S Offline
    semos
    wrote on last edited by
    #1

    Hi,

    I have QTreeView with own QAbstractItemModel implementation, sorted by custom QSortFilterProxyModel.

    Everything works fine, but when I insert new row to original model, sorting goes wrong. New item is added correctly, but it's not sorted until user 2x click to TreeView header...

    TreeView setSortingEnabled is true, dynamicSort is true too.
    beginInsertRows(), endInsertRows() is called, emit dataChanged() from setData ......

    But: when i emit layoutAboutToBeChanged() and layoutChaged() signals, application asserts in qsortfilterproxymodel.cpp on line 193 (function index_to_iterator).
    EDIT: it is not assert, iterator node is 0.

    What's wrong? Thank You for any answer...

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

      Did you check if your model is sane with the "model test":http://developer.qt.nokia.com/wiki/Model_Test tool? I know tree models can be particulary hard to get right, and a tool like this (I think there are other versions around in KDE that are even more advanced) is invaluable to help you get it right.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        semos
        wrote on last edited by
        #3

        Yes I tried this test and it was ok. Maybe, this problem is kind of special case.

        Official example "editabletreemodel" adjusted to using QSortFilterProxyModel have this issue too (new inserted items are not sorted).

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Interesting... Perhaps you should file a bugreport agains QSFPM?

          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