QML Button Pressed/Unpressed Value
-
Hello!
Im new to QML and im trying to get a Button which can deliver the Value:1 if pressed and 0 if unpressed. What properties do i need to go with? I already tried "onPressedChanged" togehter with the checkable/checked property but it doesnt work.Thanks in advance :)
-
Hello!
Im new to QML and im trying to get a Button which can deliver the Value:1 if pressed and 0 if unpressed. What properties do i need to go with? I already tried "onPressedChanged" togehter with the checkable/checked property but it doesnt work.Thanks in advance :)
-
Thank you for the fast reply.
In my specific case i want to set a value to a variable with a function e.g set_x(value).
Maybe like this:onCheckedChanged: pressed ? set_x(1) :set_x(0)
Unfortunately im still missing something.
@Kallimero said in QML Button Pressed/Unpressed Value:
onCheckedChanged: pressed ? set_x(1) :set_x(0)
or simply
onCheckedChanged : set_x(pressed )what are you missing exactly ?
-
Thank you for the fast reply.
In my specific case i want to set a value to a variable with a function e.g set_x(value).
Maybe like this:onCheckedChanged: pressed ? set_x(1) :set_x(0)
Unfortunately im still missing something.
@Kallimero Maybe the problem is in another part of your code, what do you get from using the following?
onCheckedChanged: { console.log(checked) if(checked) set_x(1) else set_x(0) }