Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QQuickStyle Class Reference

The QQuickStyle class allows configuring the application style. More...

#include <qquickstyle.h>

Collaboration diagram for QQuickStyle:

Static Public Member Functions

static QString name ()
 Returns the name of the application style.
static void setStyle (const QString &style)
 Sets the application style to style.
static void setFallbackStyle (const QString &style)

Detailed Description

The QQuickStyle class allows configuring the application style.

\inmodule QtQuickControls2

Since
5.7

QQuickStyle provides API for querying and configuring the application \l {Styling Qt Quick Controls}{styles} of Qt Quick Controls.

#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQuickStyle>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQuickStyle::setStyle("Material");
engine.load(QUrl("qrc:/main.qml"));
return app.exec();
}
\macro qGuiApp
QQmlApplicationEngine provides a convenient way to load an application from a single QML file.
static void setStyle(const QString &style)
Sets the application style to style.
\inmodule QtCore
Definition qurl.h:95
int main()
[open]
QJSEngine engine
[0]
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.
QQuickStyle is not supported when using \l {Compile-Time Style Selection}{compile-time style selection}.

To create your own custom style, see \l {Creating a Custom Style}. Custom styles do not need to implement all controls. By default, the styling system uses the \l {Basic 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.

static void setFallbackStyle(const QString &style)
See also
{Styling Qt Quick Controls}

Definition at line 14 of file qquickstyle.h.

Member Function Documentation

◆ name()

QString QQuickStyle::name ( )
static

Returns the name of the application style.

Note
The application style can be specified by passing a -style command line argument. Therefore name() may not return a fully resolved value if called before constructing a QGuiApplication.

Definition at line 431 of file qquickstyle.cpp.

◆ setFallbackStyle()

void QQuickStyle::setFallbackStyle ( const QString & style)
static
Since
5.8 Sets the application fallback style to style.
Note
The fallback style must be the name of one of the built-in Qt Quick Controls styles, e.g. "Material".
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 fallback style can be also specified by setting the QT_QUICK_CONTROLS_FALLBACK_STYLE \l {Supported Environment Variables in Qt Quick Controls}{environment variable}.

See also
setStyle(), {Using Styles in Qt Quick Controls}

Definition at line 471 of file qquickstyle.cpp.

◆ setStyle()

void QQuickStyle::setStyle ( const QString & style)
static

Sets the application style to style.

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.
See also
setFallbackStyle(), {Using Styles in Qt Quick Controls}

Definition at line 444 of file qquickstyle.cpp.


The documentation for this class was generated from the following files: