[Interest] Optimizing performance with hundreds of widgets

Adam Light aclight at gmail.com
Sun Feb 26 01:48:58 CET 2017


On Wed, Feb 15, 2017 at 9:28 AM, Gibbs, Matt <mgibbs at slac.stanford.edu>
wrote:

> Hi All,
>
> I’m working on a Qt-based project to display rapidly updating information
> from a control system.  I want to display hundreds of signals, each
> updating at about 10 Hz.  As a performance test, I’ve thrown 500 Labels in
> a grid layout, and fire a timer every 100 ms which calls setText on each
> label.  This ends up being surprisingly CPU-intensive: on reasonably modern
> hardware (2012 MacBook Pro), I use 70% of one CPU.  This doesn’t leave me
> much overhead to do anything else.
>
> Are there any best practices to reduce CPU usage in this case?
>

Though I haven't checked to see whether or not this actually affects
performance, I would suggest callint setTextFormat(Qt::PlainText) to avoid
the need to inspect the string to determine whether it's rich text.

Also, based on the image you shared, I'd guess that most of the values that
are changing might be better displayed within QLineEdit widgets. You might
find that QLineEdit has better performance because I suspect there is less
to do in terms of laying out the text and such.

Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170225/80e0d2c3/attachment.html>


More information about the Interest mailing list