From 2bc452d8a3f766fcaa61a36fcaa680a6d3c1431d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Amanda=20Hamblin-Tru=C3=A9?= Date: Mon, 26 Jun 2023 11:50:59 +0200 Subject: [PATCH] QBindable example: Replace SpinBox connection with QBindable Made this change because there was no example of the interaction between QBindable and non-bindable properties. Task-number: QTBUG-114689 Change-Id: Ief7662f8af5e6fab32491418fa35f0daa937819d Reviewed-by: Ulf Hermann (cherry picked from commit 19b0800555e7850682a6556c0569e1e2ea963c79) Reviewed-by: Qt Cherry-pick Bot --- .../bindableproperties/bindablesubscription/main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/corelib/bindableproperties/bindablesubscription/main.cpp b/examples/corelib/bindableproperties/bindablesubscription/main.cpp index 6cf73c13379..fb247836863 100644 --- a/examples/corelib/bindableproperties/bindablesubscription/main.cpp +++ b/examples/corelib/bindableproperties/bindablesubscription/main.cpp @@ -11,6 +11,10 @@ #include #include #include +#include +#include +#include +#include int main(int argc, char *argv[]) { @@ -49,9 +53,8 @@ int main(int argc, char *argv[]) }); QSpinBox *ageSpinBox = w.findChild("ageSpinBox"); - QObject::connect(ageSpinBox, &QSpinBox::valueChanged, [&](int value) { - user.setAge(value); - }); + QBindable ageBindable(ageSpinBox, "value"); + user.bindableAge().setBinding([ageBindable](){ return ageBindable.value();}); QLabel *priceDisplay = w.findChild("priceDisplay");