QQuickStyle Class
The QQuickStyle class allows configuring the application style. More...
| Header: | #include <QQuickStyle> |
| qmake: | QT += quickcontrols2 |
| Since: | Qt 5.7 |
This class was introduced in Qt 5.7.
Detailed Description
QQuickStyle provides API for querying and configuring the application styles of Qt Quick Controls.
#include <QGuiApplication> #include <QQmlApplicationEngine> #include <QQuickStyle> int main(int argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQuickStyle::setStyle("Material"); QQmlApplicationEngine engine; engine.load(QUrl("qrc:/main.qml")); return app.exec(); }
Note: The style must be configured before loading QML that imports Qt Quick Controls. It is not possible to change the style after the QML types have been registered.
The style can also be specified as a path to a custom style, such as ":/mystyle". See Creating a Custom Style for more details about building custom styles. Custom styles do not need to implement all controls. By default, the styling system uses the Default style as a fallback for controls that a custom style does not provide. It is possible to specify a different fallback style to customize or extend one of the built-in styles.
QQuickStyle::setStyle(":/mystyle"); QQuickStyle::setFallbackStyle("Material");
See also Styling Qt Quick Controls.