QBindable example: Replace SpinBox connection with QBindable

Made this change because there was no example of the interaction
between QBindable and non-bindable properties.

Pick-to: 6.6 6.5
Task-number: QTBUG-114689
Change-Id: Ief7662f8af5e6fab32491418fa35f0daa937819d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Amanda Hamblin-Trué 2023-06-26 11:50:59 +02:00
parent 0be35f3a7b
commit 19b0800555

View File

@ -11,6 +11,10 @@
#include <QPushButton> #include <QPushButton>
#include <QRadioButton> #include <QRadioButton>
#include <QSpinBox> #include <QSpinBox>
#include <QProperty>
#include <QString>
#include <QDateTimeEdit>
#include <QBindable>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
@ -49,9 +53,8 @@ int main(int argc, char *argv[])
}); });
QSpinBox *ageSpinBox = w.findChild<QSpinBox *>("ageSpinBox"); QSpinBox *ageSpinBox = w.findChild<QSpinBox *>("ageSpinBox");
QObject::connect(ageSpinBox, &QSpinBox::valueChanged, [&](int value) { QBindable<int> ageBindable(ageSpinBox, "value");
user.setAge(value); user.bindableAge().setBinding([ageBindable](){ return ageBindable.value();});
});
QLabel *priceDisplay = w.findChild<QLabel *>("priceDisplay"); QLabel *priceDisplay = w.findChild<QLabel *>("priceDisplay");