Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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();
}
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
\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:94
int main()
[0]
QApplication app(argc, argv)
[0]
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 13 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 426 of file qquickstyle.cpp.

Referenced by QtQuickControls2Plugin::registerTypes(), QQuickControlsTestUtils::StyleInfo::styleName(), styleUri(), and testStyles().

+ Here is the caller graph for this function:

◆ 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 466 of file qquickstyle.cpp.

References QTypeRevision::fromVersion(), QQmlMetaType::matchingModuleVersion(), QStringLiteral, and qWarning.

+ Here is the call graph for this function:

◆ 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 439 of file qquickstyle.cpp.

References QTypeRevision::fromVersion(), QQmlMetaType::matchingModuleVersion(), qCDebug, QStringLiteral, and qWarning.

Referenced by QQuickStylePlugin::registerTypes(), runTests(), and QQuickControlsTestUtils::QQuickStyleHelper::updateStyle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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