<html><body><div style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt; color: #000000"><div>Hi,<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>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 <strong>GPU</strong>.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><strong>1. First approach</strong><br data-mce-bogus="1"></div><div><strong>---------------------<br data-mce-bogus="1"></strong></div><div>My first approach was embedding matplotlib into PyQt5. Matplotlib is not so fast, because <em>it relies on CPU-rendering only</em>.<br data-mce-bogus="1"></div><div><br></div><div><strong>2. Second approach</strong><br data-mce-bogus="1"></div><div><strong>------------------------<br data-mce-bogus="1"></strong></div><div>I build my own PyQt5 widget and override the <span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">paintEvent()</span> method to draw a few thousand lines with the <span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">QPainter() </span>to display the live graph. The graph points are stored in numpy arrays. I simply draw lines between the points. Unfortunately, <!--StartFragment--><span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">QPainter()</span><!--EndFragment--> relies on the CPU.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>Right now, it looks like I have several options for GPU-based rendering:<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div> - <span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;"><!--EndFragment--></span><strong>QOpenGLWidget</strong></div><div> (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 <span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">QOpenGLWidget </span>instead of <span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">QWidget</span>. Apparently, I eveb don't have to change anything in the <span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">paintEvent()</span> method. Is this real? Where are the pitfalls?<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div> - <strong>PyOpenGL</strong></div><div>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.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div> - <strong>QGraphicsView</strong><br data-mce-bogus="1"></div><div>I remember reading something about <span style="font-family: "courier new", courier, monaco, monospace, sans-serif;" data-mce-style="font-family: 'courier new', courier, monaco, monospace, sans-serif;">QGraphicsView()</span> 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?<br></div><div><br data-mce-bogus="1"></div><div><br></div><div>Could you point me in the right direction please?<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div></div></body></html>