[Interest] Slider value question

deDietrich Gabriel Gabriel.deDietrich at digia.com
Fri Dec 6 12:56:52 CET 2013


Hi Damian,

On Dec 6, 2013, at 11:58 AM, Damian Ivanov <damianatorrpm at gmail.com<mailto:damianatorrpm at gmail.com>> wrote:

I have a question regarding the Slider element form Controls:
                   Slider {
                       minimumValue: 30
                       maximumValue: 100
                       stepSize: 1
                       value: mySettings.myValue
                   }
should myValue by updated when I slide the slider? Because my value
does not. I need to add
                       onValueChanged: mySettings.myValue = (value)
which results in a binding loop. What is the proper way to do it?

Yes, this is normal. Bindings only work in one direction.

What you want to do is,

mySlider.value = mySettings.myValue

where ‘mySlider’ is the slider above. You should do this when both the slider and your settings object are complete.

To update the settings, you can do it continuously with, e.g., a binding object,

Binding {
target: mySettings
property: “myValue”
value: mySlider.value
}

or only once, when you want to save your settings. For instance,

onSaveSettingsNow: mySettings.myValue = mySlider.value

where ‘saveSettingsNow’ is some signal you emit at the right moment.

Best regards,

Dr. Gabriel de Dietrich
Senior Software Developer
qt.digia.com<http://qt.digia.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131206/a67a13fe/attachment.html>


More information about the Interest mailing list