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
qqstylekitstyle.cpp File Reference

(bfb95474c96542d7789dacbb03cae2c1527c911b)

#include "qqstylekit_p.h"
#include "qqstylekitstyle_p.h"
#include "qqstylekittheme_p.h"
#include "qqstylekitcustomtheme_p.h"
#include "qqstylekitcontrolproperties_p.h"
#include "qqstylekitpropertyresolver_p.h"
#include <QtQuickTemplates2/private/qquickdeferredexecute_p_p.h>
#include <QtQml/private/qqmllist_p.h>
#include <QtGui/QGuiApplication>
#include <QtGui/QStyleHints>
#include "moc_qqstylekitstyle_p.cpp"
Include dependency graph for qqstylekitstyle.cpp:

Go to the source code of this file.

Variables

static QT_BEGIN_NAMESPACE const QString kSystem = "System"_L1
 \qmltype Style \inqmlmodule Qt.labs.StyleKit \inherits AbstractStyle
static const QString kLight = "Light"_L1
static const QString kDark = "Dark"_L1

Variable Documentation

◆ kDark

const QString kDark = "Dark"_L1
static

Definition at line 182 of file qqstylekitstyle.cpp.

◆ kLight

const QString kLight = "Light"_L1
static

Definition at line 181 of file qqstylekitstyle.cpp.

◆ kSystem

QT_BEGIN_NAMESPACE const QString kSystem = "System"_L1
static

\qmltype Style \inqmlmodule Qt.labs.StyleKit \inherits AbstractStyle

The root type for a style definition.

\l Style is the root type in StyleKit for defining a complete visual style for \l [QtQuickControls] {Qt Quick Controls}. A style lets you customize the appearance of \l {AbstractStylableControls}{every control type} — \l {ControlStateStyle::background}{backgrounds}, \l {ControlStateStyle::indicator}{indicators}, \l {ControlStateStyle::handle}{handles}, \l {ControlStateStyle::}{text}, \l {ControlStateStyle::}{padding}, and more — as well as how controls respond to states such as \l {ControlStyle::}{hovered}, \l {ControlStyle::}{pressed}, and \l {ControlStyle::}{disabled}, including animated \l {ControlStyle::transition}{transitions} between them.

Styles support \l light and \l dark color schemes through \l {Theme} {themes}, and you can add any number of \l {CustomTheme}{custom themes} as well. \l {StyleVariation}{Style variations} allow you to define alternative styling that can be applied to specific control instances or entire control types. You can also define \l {CustomControl} {custom controls} to extend the style beyond the built-in control set.

The following example shows a minimal style that defines some structural properties shared by all themes, with separate light and dark themes for colors:

For a more complete example, see the \l{StyleKit Example}.

\labs

See also
Theme, CustomTheme, StyleVariation, ControlStyle, DelegateStyle, CustomControl, {qtlabsstylekit-property-resolution.html}{Property Resolution}

\qmlproperty list<string> Style::customThemeNames \readonly

The names of all the \l {CustomTheme}{custom themes} defined in the style. This does not include the \l{themeNames}{built-in themes.}

See also
themeNames, themeName, CustomTheme

\qmlproperty Component Style::dark

The dark theme component. It's instantiated and applied when the system is in dark mode and \l themeName is "System", or when \l themeName is explicitly set to "Dark".

See also
light, themeName, {qtlabsstylekit-theme.html}{Theme}

\qmlproperty Style Style::fallbackStyle

The fallback style used to resolve properties that are not explicitly set in this style. When a property is not found in the style or its active theme, StyleKit looks it up in the fallback style.

By default, the fallback style is set to an internal style that provides a basic appearance similar to the \l {Qt Quick Controls - Basic Style}{Basic} style.

You can set this to a custom Style, or to null to disable fallback resolution entirely. Note that setting it to null means starting from a completely clean slate, which requires you to set many more properties than otherwise needed. A reference implementation of a fallback style can be found \l {qtlabsstylekit-fallbackstyle.html}{here.}

See also
{qtlabsstylekit-property-resolution.html}{Property Resolution}

\qmlproperty Component Style::light

The light theme component. It's instantiated and applied when the system is in light mode and \l themeName is "System", or when \l themeName is explicitly set to "Light".

See also
dark, themeName, {qtlabsstylekit-theme.html}{Theme}

\qmlproperty palette Style::palette \readonly

The palette of the control being styled.

Use this palette to bind colors in the style to the \l {StyleReader::palette()}{palette} of the control being styled. If the application assigns a different palette to a control, the style will adapt, and the control will repaint.

See also
{StyleReader::palette()} {StyleReader.palette}

\qmlproperty Theme Style::theme \readonly

The currently active theme instance. It's instantiated from either the \l {light}{light theme component}, the \l {dark}{dark theme component}, or one of the \l {CustomTheme}{custom themes}, depending on \l themeName.

When resolving a style property, StyleKit first looks for it in this theme (\l {StyleVariation}{StyleVariations} aside). If the property is not found, it falls back to search for it in the \l Style.

See also
themeName, light, dark

\qmlproperty string Style::themeName

The name of the currently active theme. The default value is "System", which automatically choose between \l light or \l dark depending on the color scheme reported by \l QStyleHints::colorScheme.

You can set this property to change the current theme of this style.

Supported values: \list

  • "System" \mdash follows \l QStyleHints::colorScheme (default)
  • "Light" \mdash forces the \l light theme
  • "Dark" \mdash forces the \l dark theme
  • \l {customThemeNames}{Any custom theme name} \endlist
Note
Themes are local to the \l Style where they are defined, and can only be set as the current theme for that style. For the current theme to take effect, the style it belongs to must also be the \l{StyleKit::style}{current style} in the application.
See also
themeNames, theme

\qmlproperty list<string> Style::themeNames \readonly

The names of all available themes, including "System", "Light", "Dark", and any \l {customThemeNames}{custom themes.}

See also
themeName, customThemeNames

Definition at line 180 of file qqstylekitstyle.cpp.