Solved CheckBox. Slot for when change is done by UI
-
Hi,
Currently my code uses onCheckedChanged for calling some code when check-box value has changed. This is causing me some problems.
I want some code to be called only when the change is done by UI (user clicks on the checked box). Is there some slot to do this directly? I have my work arounds, but those will always cause the code to be messy.
-
@Ankit.Jain what about the clicked signal ?
https://doc.qt.io/qt-5/qabstractbutton.html#clicked -
onToggled
is what you need:This signal is emitted when a checkable button is interactively toggled by the user via touch, mouse, or keyboard.
-
@J.Hilk I'll try that out. Seems like my vision is starting to narrow down in these things. Thanks for the help
-
@GrecKo true, but usually you toggle the Checkbox from code vis setChecked, and that also triggers the signal
This may be the result of a user action, click() slot activation, or because setChecked() is called.
?
-
@J.Hilk You are talking about
QWidget
QCheckBox
, OP is asking aboutQtQuick.Controls
(2?)CheckBox
-
@GrecKo
you are absolutely correct.I'm off my game to day! I think I may require more sleep....