Results 1 to 5 of 5

Thread: QAbstractProxyModel not getting notified when rows are inserted or removed.

  1. #1
    Join Date
    May 2011
    Posts
    20
    Platforms
    Unix/X11
    Thanked 3 Times in 3 Posts

    Default QAbstractProxyModel not getting notified when rows are inserted or removed.

    I have tableview with a custom model along with a tree that has a proxy model.
    the proxyModel source model is set to the custom tableview's model.

    The table and tree both display data correctly upon creation.
    The problem is when I add or remove rows.
    The table gets updated correctly but the tree does not.

    Is there a reason why the proxy model does not get notified when rows are being inserted/removed?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QAbstractProxyModel not getting notified when rows are inserted or removed.

    Did you connect to appropriate signals in the source model to get updates?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2011
    Posts
    20
    Platforms
    Unix/X11
    Thanked 3 Times in 3 Posts

    Default Re: QAbstractProxyModel not getting notified when rows are inserted or removed.

    I assume so In the source model I emit dataChanged in setData. I also call beginInsertRows()/endInsertRows() when inserting and beginRemoveRows()/endRemoveRows() when removing.

    In the proxy model I do not connect to any signals as I thought by doing what I mentioned above would handle that for me.


    Added after 36 minutes:


    I attached the rowsInserted() signal to a slot within the proxy model and it now updates correctly.

    The next problem I am having is that if I have expanded children on the tree they collapse when the row is inserted.
    Last edited by snydesc; 28th September 2012 at 18:54.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QAbstractProxyModel not getting notified when rows are inserted or removed.

    Quote Originally Posted by snydesc View Post
    The next problem I am having is that if I have expanded children on the tree they collapse when the row is inserted.
    It seems like something is emitting modelReset().
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2011
    Posts
    20
    Platforms
    Unix/X11
    Thanked 3 Times in 3 Posts

    Default Re: QAbstractProxyModel not getting notified when rows are inserted or removed.

    Fixed it I was passing in the start and end rows that got returned from the rowsInserted signal as the inserPosition and numberOfRows paramaters for insertRows() which confused the view.

Similar Threads

  1. How to be notified on dragEnterEvent?
    By tuxit in forum Qt Quick
    Replies: 6
    Last Post: 12th August 2011, 13:29
  2. QListView scrolls to top when rows inserted
    By woodtluk in forum Qt Programming
    Replies: 2
    Last Post: 8th October 2010, 17:26
  3. Replies: 2
    Last Post: 25th January 2010, 21:56
  4. How to be notified when a child changes?
    By mooreaa in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2008, 14:04
  5. viewing removed but not submitted rows
    By maxel in forum Qt Programming
    Replies: 6
    Last Post: 6th October 2006, 18:20

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
  •  
Qt is a trademark of The Qt Company.