Results 1 to 3 of 3

Thread: dataChanged does not re-sort the view

  1. #1

    Question dataChanged does not re-sort the view

    Good day, using qt4.3

    1. My configuration:

    MyModel (from QAbstractItemModel)

    MySortFilter (from QSortFilterProxyModel)

    MyView (from QTreeView)

    2. MyModel is using external data source, which is a list of items, each item has its own label, so when label is changed in external source I would like to update it in the MyView and automatically re-sort elements. At the moment, I'm emitting dataChange signal for changed indexes and MyView successfully updates these indexes. The problem is that items are not re-sorted.

    3. Note, that on initial model load strings are sorted correctly and after emitting dataChange signal I can see that MySortFilter's lessThan and filterAcceptsRow are called. Moreover, I can see that layoutChange signal is received by MyView.

    4. MySortFilter is using dynamic filter, enabled with setDynamicSortFilter(true)

    Any suggestions?

    Thanks!

  2. #2
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: dataChanged does not re-sort the view

    I have a similar setup, except I do not sub-class QSortFilterProxyModel and QTreeView and use them directly. The sorting works as expected in all cases, including inserting, removing and re-naming the items.

    What happens when you insert a new item? Is the view re-sorted properly?

  3. #3

    Default Re: dataChanged does not re-sort the view

    Problem is solved, was due to error in :arent() model's method.

Similar Threads

  1. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 19:21
  2. Model, View and Proxy
    By No-Nonsense in forum Qt Programming
    Replies: 2
    Last Post: 21st November 2006, 08:50
  3. Drag and drop items in view to sort order
    By Big Duck in forum Qt Programming
    Replies: 1
    Last Post: 25th May 2006, 19:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.