[PyQt] Multithreaded Update of the QStandardItemModel Data
Christian Schulze
c.schulze at tlk-thermo.com
Mon Mar 12 21:52:33 GMT 2018
Hi Florian,
I need to update many items continuously. Several rows are updated at least once per second. For some use cases I have 20000 rows in total. I prepared all the data (new/modified/removed items), so that hardly any calculation is done in the main thread.
However, the main thead seems to be blocked for too long. The GUI seems to freeze for a short moment when I update the data. This is really annoying when you're working with the application and I'd like to fix that.
I had expected that I'm allowed to modify the item model, since the GUI thread only reads data. I don't care if an intermediate state is displayed.
So I need to implement my own threadsafe item model? Is any python based item model implementation threadsafe due to the GIL? Is the interaction of python and C++ fast enough to do this?
Thanks,
Christian
Von: Florian Bruhin [mailto:me at the-compiler.org]
Gesendet: Montag, 12. März 2018 22:13
An: Christian Schulze <c.schulze at tlk-thermo.com>
Cc: pyqt at riverbankcomputing.com
Betreff: Re: [PyQt] Multithreaded Update of the QStandardItemModel Data
Hi,
On Mon, Mar 12, 2018 at 08:59:11PM +0000, Christian Schulze wrote:
> I'm trying to update the QStandardItemModel data from another thread. This causes several issues:
>
> [...]
QStandardItemModel is part of QtGui, and stuff in QtGui is not
threadsafe and must be used from the main (GUI) thread only.
> It would be great if someone could tell me how to fix this!
Your only option is pretty much "don't do this". Why do you need to
modify a QStandardItemModel from a non-main thread?
Florian
--
https://www.qutebrowser.org | me at the-compiler.org<mailto:me at the-compiler.org> (Mail/XMPP)
GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180312/2020d1d7/attachment.html>
More information about the PyQt
mailing list