[PyQt] QOpenGLWidget

V. Armando Sole sole at esrf.fr
Sun Sep 22 19:01:51 BST 2019


Hello,

Perhaps you want to give a try at the silx library 
(http://www.silx.org/doc/silx/latest/). I provides high-level PyQt 
visualization widgets with a dual backend (matplotlib and PyOpenGL) so 
that one does not need to know any OpenGL to get the performance.

Best regards,

Armando

On 22.09.2019 17:07, kristof.mulier at telenet.be wrote:
> Hi,
> 
> I'm building an application in PyQt5 for which I need to draw 2D live
> graphs. I'm looking for a way to render them with the GPU.
> 
> 1. FIRST APPROACH
> 
> ---------------------
> 
> My first approach was embedding matplotlib into PyQt5. Matplotlib is
> not so fast, because _it relies on CPU-rendering only_.
> 
> 2. SECOND APPROACH
> 
> ------------------------
> 
> I build my own PyQt5 widget and override the paintEvent() method to
> draw a few thousand lines with the QPainter() to display the live
> graph. The graph points are stored in numpy arrays. I simply draw
> lines between the points. Unfortunately,  QPainter() relies on the
> CPU.
> 
> Right now, it looks like I have several options for GPU-based
> rendering:
> 
>  - QOPENGLWIDGET
>  (see https://doc.qt.io/qt-5/qopenglwidget.html). From what I read on
> the Qt docs, it looks too good to be true. I would simply need to
> subclass QOpenGLWidget instead of QWidget. Apparently, I eveb don't
> have to change anything in the paintEvent() method. Is this real?
> Where are the pitfalls?
> 
>  - PYOPENGL
> Python bindings for OpenGL. I have no OpenGL experience. I found the
> following tutorial: https://www.labri.fr/perso/nrougier/python-opengl/
> . Great, but I'm afraid to spend a lot of time on this. When I scroll
> through the tutorial, it appears to me that the focus is on 3D shapes.
> I don't need that.
> 
>  - QGRAPHICSVIEW
> 
> I remember reading something about QGraphicsView() in a StackOverflow
> answer. It would be a Qt class to draw lots of shapes. But can it
> handle thousands of tiny lines that form the live graph? Does it rely
> on the CPU or the GPU for rendering?
> 
> Could you point me in the right direction please?
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt


More information about the PyQt mailing list