Qt 从中央QML滑杆手柄

Qt 从中央QML滑杆手柄,qt,qml,qtquickcontrols,Qt,Qml,Qtquickcontrols,在qml中的幻灯片栏中,幻灯片从头开始。我们有没有办法指定从中心开始。就像向左拖动时,它应该显示颜色。就像有一个负滑块 我尝试过类似的方法,但对我来说(橙色进度)应该从中心开始,像平衡条一样从中心左右传播 import QtQuick 2.0 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 Item { Slider { anchors.centerIn: parent val

在qml中的幻灯片栏中,幻灯片从头开始。我们有没有办法指定从中心开始。就像向左拖动时,它应该显示颜色。就像有一个负滑块

我尝试过类似的方法,但对我来说(橙色进度)应该从中心开始,像平衡条一样从中心左右传播

import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4

Item {
    Slider {
        anchors.centerIn: parent
        value: 0.5
        width: 400
        style: SliderStyle {
            groove: Rectangle {
                implicitHeight: 2
                color: "lightgrey"
                radius: 3

                Rectangle {
                    implicitHeight: 2
                    color: "orange"
                    radius: 3
                    implicitWidth: control.value * parent.width

                }
            }             
        }
    }
}

那么你在找这样的东西

Slider {
    id: slide
    anchors.centerIn: parent
    minimumValue: -1
    maximumValue: 1
    value: 0.0
    width: 400
    style: SliderStyle {
        groove: Rectangle {
            implicitHeight: 2
            color: "lightgrey"
            radius: 3

            Rectangle {
                anchors {
                    left: (control.value > 0 ? parent.horizontalCenter : undefined)
                    right: (control.value <= 0 ? parent.horizontalCenter : undefined)
                }

                implicitHeight: 2
                color: "orange"
                radius: 3
                width: Math.abs(control.value) * parent.width / 2

            }
        }
    }
}
滑块{
id:幻灯片
anchors.centerIn:父对象
最小值:-1
最大值:1
数值:0.0
宽度:400
样式:滑块样式{
凹槽:矩形{
八:2
颜色:“浅灰色”
半径:3
长方形{
锚定{
左:(control.value>0?parent.horizontalCenter:未定义)

右:(control.value For QtQuick.Controls 1您有
minimumValue
maximumValue
。在QtQuick.Controls 2中,您有
from
to
。颜色的东西,我不明白。@Derm For me(橙色进度)应该从中心开始,像平衡一样从中心左右传播……这就是我想要做的