Qt OpenGL

Introduction

The Qt OpenGL module makes it easy to use OpenGL in Qt applications. It provides an OpenGL widget class that can be used just like any other Qt widget, except that it opens an OpenGL display buffer where you can use the OpenGL API to render the contents.

The Qt OpenGL module is implemented as a platform-independent Qt/C++ wrapper around the platform-dependent GLX (version 1.3 or later), WGL, or AGL C APIs. Although the basic functionality provided is very similar to Mark Kilgard's GLUT library, applications can use the other Qt modules to implement the rest of the user interface.

The Qt OpenGL C++ Classes page gives an overview over the available classes in this module.

Using the Module

Using a Qt module requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake.

Building with CMake

Use the find_package() command to locate the needed module components in the Qt5 package:

 find_package(Qt6 COMPONENTS OpenGL REQUIRED)
 target_link_libraries(mytarget Qt6::OpenGL)

See also the Build with CMake overview.

Building with qmake

To configure the module for building with qmake, add the module as a value of the QT variable in the project's .pro file:

 QT += opengl

Module Evolution

Porting to Qt 6 - Qt OpenGL lists important changes in the module API and functionality that were done for the Qt 6 series of Qt.

Licenses and Trademarks

The Qt OpenGL module is available under commercial licenses from The Qt Company. In addition, it is available under free software licenses: The GNU Lesser General Public License, version 3, or the GNU General Public License, version 2. See Qt Licensing for further details.

OpenGL® is a trademark of Silicon Graphics, Inc. in the United States and other countries.