Search code examples
python-3.xqmlpyside6

Is there a way to specify a specific version of OpenGL for use in QML Charts?


I'm working on an application that graphs some data with a fairly large number of points (~2^16 points). Without the use of OpenGL, this is very laggy, but runs buttery smooth with OpenGL. I'm using PySide6 (Python 3.9.1) and QML 6.7.

The issue is that it works fine on my system, but when a colleague clones my repository, he cannot see the LineSeries. The application isn't throwing any errors, and printing the count property of the series shows the data is there. However, when OpenGL is turned off on the LineSeries, it is visible (but laggy).

I ran DirectX Diagnostics on both of our machines and his graphics driver is two years old (I'll attach both outputs with just the graphics data for brevity), so I think that might be it.

This application will eventually be distributed to multiple computers and I would like it to work out of the box without needing to update graphics drivers on those computers.

Is there a way to specify the version of OpenGL used by Qt/QML? I'd imagine if I can use a slightly older version of OpenGL, it's more likely that it will be supported by older drivers.


Solution

  • To force Qt6 to use OpenGL you need to set https://doc.qt.io/qt-6/qquickwindow.html#setGraphicsApi with QSGRendererInterface::OpenGL To specify which OpenGL version to use (and also select Core/Compability profile MSAA and etc.) you need to set default QSurfaceFormat https://doc.qt.io/qt-6/qsurfaceformat.html#setDefaultFormat OpenGL version is selected by setting major and minor version.

    Both static functions have to be called before QApplication constructor, to have any effect.