August 20, 2012

albertoMirada albertoMirada
Lab Rat
7 posts

Range of dataChanged needed

 

Hello everyone:

I have a subclass of QAbstractListModel, used from a QML list. This model has, for example, 3 items. It receives an update with 2 new items, and data changes in the other 3 elements. I call beginInsertRows/endInsertRows (because I have 2 new items), but my cuestion is… how should I emit the dataChanged signal? should i include the indexes for new items (from item 0 to item 4 then) or only for old data that really changed (from item 0 to item2)?

I have the same doubt when items are removed and there are data changes in items that remains.

thanks in advance and have a good day

2 replies

August 20, 2012

Gerolf Gerolf
Area 51 Engineer
3213 posts

send the dataChanged signals for the smallest possible scope (not for new items, they are definitly painted new). The dataChange signal is needed by the views to update themselves.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

August 21, 2012

albertoMirada albertoMirada
Lab Rat
7 posts

Thanks a lot, Gerolf.

 
  ‹‹ [SOLVED]Application quits if any dialog is invoked and main gui is hidden      Read iTune xml Library ››

You must log in to post a reply. Not a member yet? Register here!