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 <ulf.hermann@qt.io> (cherry picked from commit 19b0800555e7850682a6556c0569e1e2ea963c79) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
fe36efc625
commit
2bc452d8a3
@ -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");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user