+ Reply to Thread
Results 1 to 2 of 2

Thread: QSortProxyModel isnt notified when the sourceModel dies

  1. #1
    Join Date
    Jul 2012
    Posts
    155
    Thanks
    5
    Thanked 7 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QSortProxyModel isnt notified when the sourceModel dies

    Hey,

    I have a QSortProxyModel that leeches off another model that I set with setSourceModel().

    When the sourceModel is destroyed, but the QSortProxyModel is still attached to the GUI, it ends up showing ugly empty rows (see screenshot). At this point, sourceModel() method returns NULL and my overriden rowCount() in the QSortProxyModel also returns 0.

    But it looks like this isnt enough, I guess this should trigger a reset_model signal, which it seems isnt done automatically when the sourceModel dies.

    Am I expected to monitor the lifetime of the sourceMOdel on my own? Seems unnecessary, and I already take care of rowCount().
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    3,609
    Thanks
    210
    Thanked 554 Times in 544 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QSortProxyModel isnt notified when the sourceModel dies

    I am guessing that QSortProxyModel (QSPM) listens for the source model's destroyed() signal, so it sets the sourceModel() pointer to null. I have found that QSPM doesn't emit signals that I would expect when the model changes (like dataChanged()), but does emit layoutChanged(). Have you checked for that?
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

+ Reply to Thread

Similar Threads

  1. Replies: 0
    Last Post: 17th March 2010, 12:17
  2. Replies: 5
    Last Post: 14th May 2009, 09:06
  3. My QThread dies
    By Althor in forum Qt Programming
    Replies: 1
    Last Post: 10th November 2008, 14:08
  4. QList<char*> dies
    By thomaspu in forum Qt Programming
    Replies: 11
    Last Post: 15th March 2008, 22:47
  5. Detect when a TCP Server dies
    By jimroos in forum Qt Programming
    Replies: 1
    Last Post: 3rd July 2007, 23:40

Tags for this Thread

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