在本页

StyleKit QML Type

用于设置和访问当前样式的单例。更多

Import Statement: import Qt.labs.StyleKit

属性

方法

详细说明

StyleKit 是一个用于设置应用程序Style 的单例。

// Main.qml

import QtQuick
import Qt.labs.StyleKit

ApplicationWindow {
    id: app
    width: 1024
    height: 800
    visible: true

    // Assign the style to be used
    StyleKit.style: PlainStyle {}

    // Controls are used as normal
    Column {
        anchors.fill: parent
        anchors.margins: 10
        spacing: 10

        Button {
            text: "Button"
        }

        Slider {
            width: 200
        }
    }
}

它还为全局 StyleKit 配置和调试提供属性。

注意: Qt.labs 模块中的类型不保证在未来版本中保持兼容。

另请参阅 StyleStyleVariation

属性文档

debug : StyleKitDebug [read-only]

运行时调试工具,可用于跟踪特定Control 的样式属性。

style : Style

应用程序的活动样式。

将其设置为Style 实例,可将其应用于所有Qt Quick 控件

// Main.qml

import QtQuick
import Qt.labs.StyleKit

ApplicationWindow {
    id: app
    width: 1024
    height: 800
    visible: true

    // Assign the style to be used
    StyleKit.style: PlainStyle {}

    // Controls are used as normal
    Column {
        anchors.fill: parent
        anchors.margins: 10
        spacing: 10

        Button {
            text: "Button"
        }

        Slider {
            width: 200
        }
    }
}

注意: 为获得最佳启动性能,请在根ApplicationWindow 上设置样式,然后再设置子控件。

另请参阅 styleUrlStyle

styleUrl : string

style 的替代方案,可从 URL 加载Style

另请参阅 style

transitionsEnabled : bool

控制是否全局启用过渡效果。

将其设置为false 可禁用当前样式中的所有过渡效果。

默认值为true

另请参阅 ControlStyle::transition

方法文档

bool styleLoaded()

当活动style 及其当前theme 都已完成加载时,返回true 。这可用于推迟依赖于已解析样式属性的初始化逻辑。

另请参阅 styletheme

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.