[PyQt] QGraphicsView very slow under Linux and Mac OS X
apaku at gmx.de
Wed Apr 3 14:24:36 BST 2013
On Wed, Apr 3, 2013 at 2:15 PM, Clemens Brunner
<clemens.brunner at tugraz.at>wrote:
> I've also posted this question as a bug report at qt-project.org (
> https://bugreports.qt-project.org/browse/PYSIDE-151), but this is also a
> PyQt issue.
> QGraphicsView is apparently very slow under Linux and Mac OS X. I've
> attached an example program (runs with PySide or PyQt). The signals should
> be updated every 25ms; the actual timer intervals are displayed on the
> console. Now under Linux and Mac OS X, the graphics get slower with
> increasing window size. In full screen, the timer intervals are around
> 100ms instead of 25ms on my machines.
> This problem does not exist under Windows. Here, the intervals are not
> affected by window size, and the intervals stay at the given values.
> Interestingly, the program runs perfectly fast even in a Windows inside a
> Furthermore, this problem is PySide (or PyQt) specific, because this
> behavior does not occur when I use Qt from C+. In C+, the program works as
> expected on all three platforms.
first of all, QTimer gives you no guarantee that it'll fire exactly after
the given amount of time. In particular not with such small timeouts and
when having non-trivial paint functions like yours. QTimer is bound to the
event loop, hence cannot fire if the loop is being blocked by something. If
you simplify the paint function the effect will be much less dramatic.
That being said, here with Qt4.8 even a full-screen window will not cause a
significant slowdown, except during the resize phase. Once the resize is
done the timer fires every 25 ms again. So I guess the calculation inside
the paint function simply take some time and once the widget doesn't resize
anymore the paint function is not called anymore.
If you need high precision timers then you'll need to write
platform-specific code. QTimer is not meant for that.
Why this works better on Windows with Py(Qt/Side) can have many reasons,
the whole graphicsstack is different there, the QTimer might be implemented
differently there. Maybe windows delays the painting during resize somewhat
more so that there are less repaint-events given to Qt or maybe the
functions used in your paint() are more optimized on Windows.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt