Results 1 to 2 of 2

Thread: Bad selection behavior when using custom proxy model

  1. #1
    Join Date
    Sep 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android

    Default Bad selection behavior when using custom proxy model

    Hi,

    I have created a custom proxy model(subclass of QAbstractProxyModel) to be able show certain elements in a tree I am intrested in. The source model is s subclass of QAbstractItemModel. I have implemented mapFromSource(), mapToSource(), columnCount(), rowCount(), index(), parent(), data(), hasChildren(). When I use the proxy model in my QTreeView the result looks like I expected, but the selection behaivor does not work correctly. When I select a new row in the tree view the old selection is sometimes not updated/removed(I have attached a png file showing this). I have tested my proxy model against https://qt-project.org/wiki/Model_Test and it works fine.

    Does anyone have a hint what I am missing/doing wrong? How does the selection work?
    I notice if I return with an extra row when rowCount() is called everything works fine and the selection is updated correctly(model test will of course not pass since I return an invalid row).

    Thanks!
    Attached Images Attached Images

  2. #2
    Join Date
    Sep 2013
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android

    Default Re: Bad selection behavior when using custom proxy model

    I got invalid index during selection since I didn't implemented the silbings() function in my proxymodel. Implementing the siblings() function solved all my issues.

Similar Threads

  1. Replies: 24
    Last Post: 18th September 2013, 06:35
  2. Replies: 1
    Last Post: 29th August 2013, 05:41
  3. Custom Model and Proxy Model
    By frank100 in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2010, 14:30
  4. Replies: 1
    Last Post: 18th November 2009, 23:21
  5. Custom proxy model issue
    By Khal Drogo in forum Qt Programming
    Replies: 13
    Last Post: 30th November 2007, 12:41

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.