Results 1 to 5 of 5

Thread: How to tell a QAbstractItemModel that data has been inserted or removed? (4.8)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to tell a QAbstractItemModel that data has been inserted or removed? (4.8)

    Quote Originally Posted by JasonC View Post
    Thanks. I did see that but was still uncertain: The documentation is worded in a way that makes it appear that beginInsertRow/endInsertRow should be called when the *model* is causing the row insertion
    Whenever rows are inserted, independend on whether they are insterted through the model's API, e.g. by a view, or by the model itself.

    Quote Originally Posted by JasonC View Post
    The other thing that confused me about those is: Does that mean I need to add the ability to my underlying data class to emit signals or otherwise notify the list model *before* data is changed as well as after, so that I can call beginInsertRow and endInsertRow before and after the data changes? Or can I just call begin+end together after the data changes... ?
    I think you can do that.

    Usually, when I am dealing with an uncooperative data source, I'll try to make the model still behave like it would with a cooperative data base by making sure rowCount() and data() work with the old row indexes until after beginInsertRows() returns.

    But I think the standard views only use the about signal to avoid updating until the end of the change.

    Cheers,
    _

  2. The following user says thank you to anda_skoa for this useful post:

    JasonC (5th March 2015)

Similar Threads

  1. How to make QAbstractItemModel 's data checkable
    By nifei in forum Qt Programming
    Replies: 12
    Last Post: 1st April 2013, 19:52
  2. Replies: 4
    Last Post: 28th September 2012, 18:19
  3. Data from model not inserted in QTableView
    By schmimona in forum Qt Programming
    Replies: 1
    Last Post: 10th August 2011, 05:16
  4. How to fill an inserted column with data?
    By croo in forum Qt Programming
    Replies: 3
    Last Post: 12th December 2010, 19:58
  5. Replies: 4
    Last Post: 4th September 2009, 08:33

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