QQuickStyle 類允許配置應用程序樣式。 更多...
| 頭: |
#include <QQuickStyle>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS QuickControls2)
target_link_libraries(mytarget PRIVATE Qt6::QuickControls2)
|
| qmake: |
QT += quickcontrols2
|
| QString | name () |
| void | setFallbackStyle (const QString & style ) |
| void | setStyle (const QString & style ) |
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 app(argc, argv); QQuickStyle::setStyle("Material"); QQmlApplicationEngine engine; engine.load(QUrl("qrc:/main.qml")); return app.exec(); }
注意: 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 compile-time style selection .
To create your own custom style, see 創建自定義樣式 . Custom styles do not need to implement all controls. By default, the styling system uses the 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.
QQuickStyle::setStyle("MyStyle"); QQuickStyle::setFallbackStyle("Material");
另請參閱 風格化 Qt Quick Controls .
[static]
QString
QQuickStyle::
name
()
Returns the name of the application style.
注意:
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
.
[static]
void
QQuickStyle::
setFallbackStyle
(const
QString
&
style
)
Sets the application fallback style to style .
注意: 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
環境變量
.
另請參閱 setStyle () 和 在 Qt Quick Controls 中使用風格 .
[static]
void
QQuickStyle::
setStyle
(const
QString
&
style
)
把應用程序樣式設為 style .
注意: 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.
另請參閱 setFallbackStyle () 和 在 Qt Quick Controls 中使用風格 .