Bug 474611

Summary: PlasmaComponent Slider with unexpected init value behavior
Product: [Frameworks and Libraries] libplasma Reporter: Schlaefer <openmail+kde>
Component: componentsAssignee: Plasma Bugs List <plasma-bugs-null>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: me, nate, notmart
Priority: NOR    
Version First Reported In: 5.110.0   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Schlaefer 2023-09-17 12:30:34 UTC
SUMMARY

I was working on a plasma widget with a horizontal slider which should be shown vertical in some cases and encountered unexpected event feedback in different orientations.

STEPS TO REPRODUCE

Boiled down example with two widgets which only differ in the orientation: 

```
    PlasmaComponents.Slider {
        id: horizontalSlider
        minimumValue: 0
        value: 10
        maximumValue: 100
        stepSize: 1

        Connections {
            target: horizontalSlider
            function onValueChanged() {
                console.log("horizontal slider value: " + horizontalSlider.value)
            }
        }
    }


    PlasmaComponents.Slider {
        id: verticalSlider
        minimumValue: 0
        value: 10
        maximumValue: 100
        stepSize: 1

        orientation: Qt.Vertical
        // inverted: true

        Connections {
            target: verticalSlider
            function onValueChanged() {
                console.log("vertical slider value: " + verticalSlider.value)
            }
        }
    }
```
OBSERVED RESULT

qml: vertical slider value: 90
qml: horizontal slider value: 10

EXPECTED RESULT

qml: vertical slider value: 10
qml: horizontal slider value: 10

SOFTWARE/OS VERSIONS
Operating System: EndeavourOS 
KDE Plasma Version: 5.27.8
KDE Frameworks Version: 5.110.0
Qt Version: 5.15.10
Kernel Version: 6.5.3-4-cachyos (64-bit)
Graphics Platform: Wayland
Comment 1 ratijas 2023-12-08 17:36:35 UTC
You seem to be using PlasmaComponents 2.0 (which you should've stated in the bug report btw, but I guess it from the properties that you are using here). PC2 are no longer supported, as they are based on QtQuick.Controls 1, which in turn were deprecated for quite some time, and eventually removed in Qt 6.

Please use QtQuick.Controls 2 and PlasmaComponents 3. By the way, in Qt 6 QML you won't need import versions anymore, and there would be only one — the right one — module that you should use.

Also, heads-up about Slider & ProgressBar: if you are going to change their maximum value after creation, do so before updating `value` property or else the value would get clamped.