Silex
Silex

Reputation: 2713

QML Slider value is not updating visually

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?

Upvotes: 1

Views: 3400

Answers (1)

Mitch
Mitch

Reputation: 24386

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

Upvotes: 1

Related Questions