Results 1 to 2 of 2

Thread: Custom model item deletion (Qt4.4)

  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Custom model item deletion (Qt4.4)

    Here is my custom model delete item function:

    Qt Code:
    1. /*virtual */ void ZeBaseModel::RemoveItem(ZeBaseItem & item)
    2. {
    3. int index;
    4. if ((index = mItems.indexOf(&item)) == -1) return;
    5.  
    6. mItems.remove(index);
    7.  
    8. RefreshView();
    9.  
    10. // If I don't call this one I get random crashes
    11. if (mItems.size() == 0)
    12. {
    13. reset();
    14. }
    15.  
    16. item.deleteLater();
    17. }
    To copy to clipboard, switch view to plain text mode 

    When I don't call reset when my Model delete his last item I get random crashes in my view.
    What signal or function am I supposed to call to notify the view that an item has been deleted ?

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

    Default Re: Custom model item deletion (Qt4.4)

    You need to call beginRemoveRows() and endRemoveRows() on the model in appropriate places.

  3. The following user says thank you to wysota for this useful post:

    bunjee (22nd May 2008)

Similar Threads

  1. list of custom item views?
    By Beluvius in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2008, 06:43
  2. 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.