1
votes

I am trying to create a Slider in QML. The slider's maximumValue property can change depending on certain states in my application. When the maximumValue property changes I would like to "reset" my slider so that its value property is at the maximumValue. The problem what I am encountering is that when I change the maximumValue property, my value property changes to the right property, but visually it stays at the previous maximumValue property until I don't click on the handle for example.

Here is a simple dummy code, which reproduces this issue:

import QtQuick 2.5
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.2

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    property int maxVal: 1

    Item {
        width: 20
        height: 200

        Slider {
            anchors.fill: parent

            orientation: Qt.Vertical

            maximumValue: maxVal
            minimumValue: 0
            value: 1
            stepSize: 1.0

            style: SliderStyle {
                groove: Rectangle {
                    width: control.height
                    height: control.width

                    color: "red"
                }

                handle: Rectangle {
                    width: 20
                    height: 20

                    color: "green"

                    Text {
                        anchors.centerIn: parent

                        text: control.value
                    }
                }
            }

            onMaximumValueChanged: value = maximumValue
        }
    }

    Button {
        anchors.right: parent.right

        text: "Press Me"

        onClicked: maxVal = 100
    }
}

Below you can see some screenshots of certain stages.

When the application opens: on application start

When I press the "Press Me" button, which sets the maximumValue to 100 from 1. As you can see the value did change from 1 to 100, but visually it stayed at the 1 position: on button press

Finally when I click on the handler of the slider (green rectangle), then it updates and switches value to 1 from 100. on slider handle press

Here is the same thing as a gif: slider value problem demonstrated visually

Anybody encountered this issue before?

1
@derM I am not sure what is the problem on line 45, maybe you made a typo? What do you mean you don't have this issue? If you run my dummy code and you press the button, the green handle stays at the top and says 100 for you? What Qt version are you using? I tried both 5.6.2. and 5.9.2.Silex
I should say: I thought I can't reproduce your issue. Seems I made a mistake.derM

1 Answers

1
votes

It looks like QTBUG-63354, which will be fixed in Qt 5.9.3.