Qt Environment Variables
-
Posting this here for posterity (including my future self). This has been asked many times, but most noteably:
- https://forum.qt.io/topic/28853/list-of-qt-and-qml-environment-variables/2
- Here: https://forum.qt.io/topic/37773/environment-variables
Answer
- Most variables/enums for Qt are in
QtCore.Qt
: https://doc.qt.io/qtforpython-6/PySide6/QtCore/Qt.html
Many were added in Qt5:
(a)
WA
stands forWidget Attribute
: QtCore.Qt.WidgetAttribute
(b)AA
stands forApplication Attribute
: .QtCore.Qt.ApplicationAttributeThese are used within code and set with
QAppliction.setAttribute
and tested withQApplication.testAttribue
. e.g.from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QApplication app = QApplication([]) app.setAttribute(Qt.AA_DontShowIconsInMenus, True)
There are many others that control a vast array of the items in
Qt
.-
Environment variables are often used for specific plugins and abstractions. For example
(a)
QPA
stand forQt Platform Abstraction
, which controls the platform/windowing mode your app uses: https://doc.qt.io/qt-5/qpa.html#qpa-pluginsE.g.
QT_QPA_PLATFORM=offscreen
runs your program in headless mode (no screen), which may or may not be useful for testing.
From the docs:
Qt integrates with the windowing system on the target platform using Qt Platform Abstraction (QPA). QPA is an abstraction of a windowing system which makes porting Qt to new platforms simple and quick. One such system is the Wayland protocol. Qt can be used together with Wayland as a light-weight windowing system on embedded hardware to support a multi-process graphical user interface.
The Qt Platform Abstraction uses Qt's plugin system. This plugin system provides APIs to extend Qt in specific areas (such as adding support for new image formats, database drivers, and so on) and also for writing your own extensible Qt applications which support third-party plugins.
Instructions on which values are valid are listed here (though the docs could be improved):
https://doc.qt.io/qt-5/qguiapplication.html#platformName-prop
The
Qt Wiki
seems to have a set of useful environment variable configurations for different setups:https://wiki.qt.io/Qt_6.2_Tools_and_Versions
(b) There's also the
Qt Quick Scene Graph
(QSG
) andRendering Hardware Interface
(RHI
):QSG_RHI_BACKEND=software
which you can find more about here:
Qt
QuickControls
(which I've yet to use) list environment variables here:
https://doc.qt.io/qt-5/qtquickcontrols2-environment.html
- For
QMake
(which I haven't used), supported variables are listed here:
https://doc.qt.io/qt-5/qmake-variable-reference.html
- Lastly, there's also a list of all available environment variables for
Qt5
here on GitHub:
https://github.com/pyqt/python-qt5/wiki/Qt-Environment-Variable-Reference