Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    2
    4
    3747
    Loading More Posts
    • 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
      semos last edited by

      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 Reply Quote 0
      • A
        andre last edited by

        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 Reply Quote 0
        • S
          semos last edited by

          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 Reply Quote 0
          • A
            andre last edited by

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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post