QQuickStyle
QQuickStyle
QQuickStyle类用来配置应用程序样式
Header: | #include <QQuickStyle> |
Since: | Qt 5.7 |
Static Public Members
QStringList | availableStyles() |
QString | name() |
QString | path() |
void | setFallbackStyle(const QString &style) |
void | setStyle(const QString &style) |
Detailed Description
The QQuickStyle class allows configuring the application style.
QQuickStyle provides API for querying and configuring the application styles of Qt Quick Controls 2.
#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 2. 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 2.
Member Function Documentation
[static]
QStringList QQuickStyle::availableStyles()
Returns the names of the available built-in styles.
Note: The method must be called after creating an instance of QGuiApplication.
This function was introduced in Qt 5.9.
[static]
QString QQuickStyle::name()
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.
[static]
QString QQuickStyle::path()
Returns the path of an overridden application style, or an empty string if the style is one of the built-in Qt Quick Controls 2 styles.
Note: The application style can be specified by passing a -style
command line argument. Therefore path()
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.
Note: The fallback style must be the name of one of the built-in Qt Quick Controls 2 styles, e.g. "Material".
Note: The style must be configured before loading QML that imports Qt Quick Controls 2. 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
environment variable.
This function was introduced in Qt 5.8.
See also setStyle() and Using Styles in Qt Quick Controls 2.
[static]
void QQuickStyle::setStyle(const QString &style)
Sets the application style to style.
Note: The style must be configured before loading QML that imports Qt Quick Controls 2. It is not possible to change the style after the QML types have been registered.
See also setFallbackStyle() and Using Styles in Qt Quick Controls 2.
########################
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Ollama——大语言模型本地部署的极速利器
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· Windows编程----内核对象竟然如此简单?
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
2022-03-01 Pset_RampFlightCommon
2021-03-01 IfcDotProduct
2020-03-01 IfcGrid
2019-03-01 Test2
2018-03-01 OpenGL超级宝典完整源码(第五版)