[Qt-interest] AmIRight: Can't Have Model and View on different Threads?
Arnold Krille
arnold at arnoldarts.de
Thu Aug 13 09:19:42 CEST 2009
Hi,
On Thursday 13 August 2009 08:07:01 Stephen Kelly wrote:
> Arnold Krille wrote:
> > On Friday 07 August 2009 07:36:30 Hostile Fork wrote:
> >> The short version is that I don't think it's feasible for a Model to
> >> be modified on a non-GUI thread...regardless of whether the model's
> >> data has been protected with read/write locks. If what I'm gathering
> >> is correct, then Qt should probably have an assert that a model and
> >> its view have the same thread affinity (it doesn't seem to do that now)
> > I would find such an assert quite disturbing. Because here it works well
> > to have models and views in different threads.
> Can you say more about this? How does it work with QueuedConnections? What
> happens if a row gets added then removed, and because of the queue, the
> view only gets to process the added signal after the row has been removed?
While the slot of a QueuedConnection is not called right away, it is just
converted to an event sent to the receivers event-loop. But there is no
reordering of the event-loop. So there is no way the added-slot is called
after the removed-slot in your example.
And that actually works nice. My models normally reset themselfes completely
because when the number of rows changes, the bin-width (its models used for
statistics) changes which invalids any data. So its faster to remove
everything and call reset to signal the views to get everything new...
And my models cache updates, with >5000 changed values a second, you don't
want to emit dataChanged() to often.
You can find the ((L)GPLv3) code at http://positron.physik.uni-
halle.de/EPOS/Software/ which is the last stable release, but the model/view
stuff hasn't changed in the last months...
I am also open for tests showing where my models and views are wrong. :-) The
ModelTest from QtLabs is kind of limited (but nevertheless showed me some
errors).
Have fun,
Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090813/f8c35fe9/attachment.bin
More information about the Qt-interest-old
mailing list