#include#include int main(int argc, char *argv[]) { QApplication a(argc, argv); QGLFormat format; format.setVersion(3, 3); // Set OpenGL version to 3.3 QGLWidget widget(format); widget.show(); return a.exec(); }
#includeIn this example, we are creating a QGLWidget with an OpenGL version of 4.5 using setVersion method and then printing the OpenGL version using glGetString method. Package library: QtOpenGL#include int main(int argc, char *argv[]) { QApplication a(argc, argv); QGLFormat format; format.setVersion(4, 5); // Set OpenGL version to 4.5 QGLWidget widget(format); widget.makeCurrent(); // Make the widget's context current qDebug() << "OpenGL Version: " << (char*)glGetString(GL_VERSION); return a.exec(); }