Reputation: 839
I am trying to use the new QOpenGLWidget with PySide2 and got this error at the very beginning.
PySide2: QOpenGLContext' object has no attribute 'functions'
I converted from c++ the simplest example from the documentation: https://doc.qt.io/qtforpython/PySide2/QtWidgets/QOpenGLWidget.html
def initializeGL(self):
ctx = QOpenGLContext.currentContext()
gl = ctx.functions()
gl.glClearColor(1.0, 1.0, 1.0, 1.0)
A cannot find any examples with pyside2 using QOpenGLWidget, but every example uses QGLWidget, even though its kept only for backward compatibility, and the new QOpenGLWidget shoudl be used instead. As far as I know...
Could someone show me a good and minimal working example with QOpenGLWidget with pyside2 in python? Or am I supposed to use the old QGLWidget?
PySide.version returns: "5.6.0~a1" (which is probably the Qt version) python version: 2.7.15
Upvotes: 1
Views: 900
Reputation: 285
Looking at one of the OpenGL examples in the official repository, seems like you need to obtain first the current context.
QOpenGLContext.currentContext().functions()
Another issue could be the version, since 5.6 is quite old. Can you give it a try with the latest 5.12.0 version?
Upvotes: 2