Qt has two main approaches to UI development: Qt Quick and Qt Widgets. They exist to support different types of user interfaces, and build on separate graphics engines which have been optimized for each of these types.
It is possible to combine code written in the OpenGL graphics API with both these user interface types in Qt. This can be useful when the application has its own OpenGL-dependent code, or when it is integrating with a third-party OpenGL-based renderer.
The Qt OpenGL module contains convenience classes to make this type of integration easier and faster.
Qt Widgets is typically rendered by a highly optimized and accurate software rasterizer, and the final content reproduced on screen using a method appropriate for the platform where the application is running.
But it is also possible to combine Qt Widgets with OpenGL. The main entry point for this is the QOpenGLWidget class. This class can be used to enable OpenGL rendering for a certain part of the widget tree, and the classes in the Qt OpenGL module can be used to facilitate any application-side OpenGL code.
Qt Quick is optimized for hardware-accelerated rendering. By default, it will be built on the low-level graphics API most appropriate for the target platform.
For instance, it will default to
Direct3D on Windows, whereas on macOS, it will default to
Metal. But it is also possible to manually select OpenGL as the active graphics API on platforms where this is supported.
find_package() command to locate the needed module components in the
find_package(Qt6 REQUIRED COMPONENTS OpenGL) target_link_libraries(mytarget PRIVATE Qt6::OpenGL)
See also the Build with CMake overview.
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
Changes to Qt OpenGL lists important changes in the module API and functionality that were done for the Qt 6 series of Qt.
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.
These are links to the API reference materials and related pages.
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.