如何设置开关大小

时间:2017-06-21 12:08:24

标签: qt switch-statement qml qtquick2 qt-quick

我想调整Switch的大小(如果我使用QtQuick 1.x2.x,则无关紧要。)

然而,使用参数widthheight并不起作用。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

您可以customize the Switch to your needs提供自定义indicator

默认情况下,这似乎是Item,其中有两个子项用于凹槽(children[0])和句柄(children[1])。由于在创建项目之前无法访问这些属性,因此可以使用绑定:

Switch {
    id: swch
    anchors.fill: parent

    Binding {
        target: swch.indicator
        property: 'width'
        value: swch.width
    }

    Binding {
        target: (swch.indicator ? swch.indicator.children[0] : null)
        property: 'width'
        value: swch.width
    }
}