Bug 474611 - PlasmaComponent Slider with unexpected init value behavior
Summary: PlasmaComponent Slider with unexpected init value behavior
Status: RESOLVED UNMAINTAINED
Alias: None
Product: libplasma
Classification: Frameworks and Libraries
Component: components (show other bugs)
Version: 5.110.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-17 12:30 UTC by Schlaefer
Modified: 2023-12-08 17:36 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.