I'm trying to Draw line and shapes on an existing image using PyQt5 and PyOpenGL. I have done the following so far:
QGraphicsView
QGraphicsScene()
object to itPixmap
into my scene
I also created a class called GLWidget
which inherits from QGLWidget
.
The problem is that I can not display the GLWidget
in the scene
. I mean when I do scene.addWidget(glWidget)
the functions (initializeGL
,paintGL
,...) are called but nothing shows on the screen.
I have to say that when I only display the GLWidget
like this:
glWidget = GLWidget(self)
self.setCentralWidget(glWidget)
it works fine!
Thanks in advance.
I found the solution in PyQt5 examples in github here: PyQt5 OpenGL examples
The tricky part was in the initializeGL
function which I had to do:
self.gl = self.context().versionFunctions()
self.gl.initializeOpenGLFunctions()
....
I hope it helps!