[PyQt] Dont understand QListView behavior after filling the QStandardItemModel is finished

Florian Bruhin me at the-compiler.org
Sat May 11 17:13:09 BST 2019


Hi,

On Sat, May 11, 2019 at 05:02:03PM +0200, Gottfried Müller wrote:
> The first case displays the the content of the model directly. In the second
> case a sleep command is following the filling function. In the second case
> the content appears when the sleep time ended.
> 
> But in both cases the content of QStatusBar (counter of generated items)
> appears directly after the filling process of the model is ready.
> 
> Why appears the the QListView content in the second case so late? Does an
> action exist to force the display of the items before the sleep event?

Probably due to some Qt implementation detail. Maybe QStatusBar::showMessage
forces redrawing it immediately, while QListView updates as soon as you're back
in the main loop.

> Note: You can exchange the sleep command with any procedure which needs a
> longer time. The behavior is the same.

In general, you should never block Qt's main loop, as your application will
become unresponsive. Find a way to do the same thing asynchronously, or do it
in a worker thread, or call QApplication.processEvents() regularly.

Florian

-- 
https://www.qutebrowser.org | 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 --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20190511/c223707f/attachment.sig>


More information about the PyQt mailing list