[Interest] Proper way of updating a model?

Jason H scorp1us at yahoo.com
Wed Aug 22 20:53:59 CEST 2012


I'd probably be using something like libQxt's RPC's functionality to publish updates to you and incrementally adjust the model, a row at a time. http://libqxt.bitbucket.org/doc/tip/qxtxmlrpcclient.html






________________________________
 From: Stephen Chu <stephen at ju-ju.com>
To: Interest at qt-project.org 
Sent: Wednesday, August 22, 2012 2:29 PM
Subject: [Interest] Proper way of updating a model?
 
Thanks to everyone who helped on the 64-bit internal ID question I 
posted. I end up maintaining a copy of index-and-id mapping to work 
around it.

Now I have a question on how to properly update the model. My model is a 
read-only representation of a database. I am using a QTreeView to hold 
the model. The data themselves are not tree-like but I like the visual 
of QTreeView better.

The model needs to update itself periodically from the remote database. 
I keep a QList of data IDs and rebuild the list every time I get a new 
snapshot from the database.

What's the recommended way to reflect the changes to the view? I need to 
keep the current selection and scroll position of the QTreeView between 
updates.

Do I reset the model? Or do I remove deleted rows and insert new ones?

Thanks.
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120822/b0ac1ded/attachment.html>


More information about the Interest mailing list