[solved] How to reuse Slider as Component with different MouseAreas

  • Hello!
    I have a Slider written in QML which consists of a slider field and a handle. There are some defined properties and a function:

    @property int value: 0 //the actual value of the slider
    property int maximum: 0 //the maximum value of slider scale
    property int minimum: 0 //the minimum value of the slider scale
    property int yMax: slider.height - handle.height //the maximum position the handle can be dragged to
    onValueChanged: updatePos(); //holds the value of the slider
    onYMaxChanged: updatePos(); //holds the value of the handle
    onMinimumChanged: updatePos();

    //calculates the position of the handle
    function updatePos()  {}@

    In the MouseArea of the handle I calculate the value:

    @onPositionChanged: {
    value = (maximum - minimum) * (handle.y) / yMax + minimum

    I want to use this Slider Component several times in another QML-File and I am doing it like this:

    @MySlider {
    id: slider1
    maximum: 450
    minimum: 220
    value: 220

              onPositionChanged: {
              slider1.value = mwBSC614_24_B.setHvVoltageLowLimit(value) // here I am setting some value for the backend


    So I want to set some values after the Position was changed, but it doesn't function. I think it is due to the fact that the signal positionChanged is not being recognized in this form. How can I solve this?

    Thank you beforehand,

    Best regards

  • Solved: put a signal in the slider.qml and handled it in another.qml

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.