mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-05 00:35:27 +08:00
6.6.1 original
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
#ifndef BINDABLESUBSCRIPTION_H
|
||||
#define BINDABLESUBSCRIPTION_H
|
||||
|
||||
#include <QPointer>
|
||||
#include <QBindable>
|
||||
#include <QProperty>
|
||||
|
||||
class BindableUser;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#ifndef BINDABLEUSER_H
|
||||
#define BINDABLEUSER_H
|
||||
|
||||
#include <QBindable>
|
||||
#include <QLocale>
|
||||
#include <QProperty>
|
||||
|
||||
|
@ -6,15 +6,15 @@
|
||||
#include "bindableuser.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QButtonGroup>
|
||||
#include <QBindable>
|
||||
#include <QLabel>
|
||||
#include <QLocale>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QSpinBox>
|
||||
#include <QProperty>
|
||||
#include <QString>
|
||||
#include <QDateTimeEdit>
|
||||
#include <QBindable>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -27,38 +27,38 @@ int main(int argc, char *argv[])
|
||||
// when subscription is out of scope so is window
|
||||
|
||||
// Initialize subscription data
|
||||
QRadioButton *monthly = w.findChild<QRadioButton *>("btnMonthly");
|
||||
QRadioButton *monthly = w.findChild<QRadioButton *>(u"btnMonthly"_s);
|
||||
QObject::connect(monthly, &QRadioButton::clicked, [&] {
|
||||
subscription.setDuration(BindableSubscription::Monthly);
|
||||
});
|
||||
QRadioButton *quarterly = w.findChild<QRadioButton *>("btnQuarterly");
|
||||
QRadioButton *quarterly = w.findChild<QRadioButton *>(u"btnQuarterly"_s);
|
||||
QObject::connect(quarterly, &QRadioButton::clicked, [&] {
|
||||
subscription.setDuration(BindableSubscription::Quarterly);
|
||||
});
|
||||
QRadioButton *yearly = w.findChild<QRadioButton *>("btnYearly");
|
||||
QRadioButton *yearly = w.findChild<QRadioButton *>(u"btnYearly"_s);
|
||||
QObject::connect(yearly, &QRadioButton::clicked, [&] {
|
||||
subscription.setDuration(BindableSubscription::Yearly);
|
||||
});
|
||||
|
||||
// Initialize user data
|
||||
QPushButton *germany = w.findChild<QPushButton *>("btnGermany");
|
||||
QPushButton *germany = w.findChild<QPushButton *>(u"btnGermany"_s);
|
||||
QObject::connect(germany, &QPushButton::clicked, [&] {
|
||||
user.setCountry(BindableUser::Country::Germany);
|
||||
});
|
||||
QPushButton *finland = w.findChild<QPushButton *>("btnFinland");
|
||||
QPushButton *finland = w.findChild<QPushButton *>(u"btnFinland"_s);
|
||||
QObject::connect(finland, &QPushButton::clicked, [&] {
|
||||
user.setCountry(BindableUser::Country::Finland);
|
||||
});
|
||||
QPushButton *norway = w.findChild<QPushButton *>("btnNorway");
|
||||
QPushButton *norway = w.findChild<QPushButton *>(u"btnNorway"_s);
|
||||
QObject::connect(norway, &QPushButton::clicked, [&] {
|
||||
user.setCountry(BindableUser::Country::Norway);
|
||||
});
|
||||
|
||||
QSpinBox *ageSpinBox = w.findChild<QSpinBox *>("ageSpinBox");
|
||||
QSpinBox *ageSpinBox = w.findChild<QSpinBox *>(u"ageSpinBox"_s);
|
||||
QBindable<int> ageBindable(ageSpinBox, "value");
|
||||
user.bindableAge().setBinding([ageBindable](){ return ageBindable.value();});
|
||||
|
||||
QLabel *priceDisplay = w.findChild<QLabel *>("priceDisplay");
|
||||
QLabel *priceDisplay = w.findChild<QLabel *>(u"priceDisplay"_s);
|
||||
|
||||
// Track price changes
|
||||
//! [update-ui]
|
||||
|
@ -3,7 +3,8 @@
|
||||
|
||||
/*!
|
||||
\example bindableproperties
|
||||
\title Bindable Properties Example
|
||||
\examplecategory {Data Processing & I/O}
|
||||
\title Bindable Properties
|
||||
\brief Demonstrates how the usage of bindable properties can simplify
|
||||
your C++ code.
|
||||
|
||||
|
@ -6,11 +6,14 @@
|
||||
#include "user.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QButtonGroup>
|
||||
#include <QLabel>
|
||||
#include <QLocale>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QSpinBox>
|
||||
#include <QString>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -24,40 +27,40 @@ int main(int argc, char *argv[])
|
||||
SubscriptionWindow w;
|
||||
|
||||
// Initialize subscription data
|
||||
QRadioButton *monthly = w.findChild<QRadioButton *>("btnMonthly");
|
||||
QRadioButton *monthly = w.findChild<QRadioButton *>(u"btnMonthly"_s);
|
||||
QObject::connect(monthly, &QRadioButton::clicked, &subscription, [&] {
|
||||
subscription.setDuration(Subscription::Monthly);
|
||||
});
|
||||
QRadioButton *quarterly = w.findChild<QRadioButton *>("btnQuarterly");
|
||||
QRadioButton *quarterly = w.findChild<QRadioButton *>(u"btnQuarterly"_s);
|
||||
QObject::connect(quarterly, &QRadioButton::clicked, &subscription, [&] {
|
||||
subscription.setDuration(Subscription::Quarterly);
|
||||
});
|
||||
QRadioButton *yearly = w.findChild<QRadioButton *>("btnYearly");
|
||||
QRadioButton *yearly = w.findChild<QRadioButton *>(u"btnYearly"_s);
|
||||
QObject::connect(yearly, &QRadioButton::clicked, &subscription, [&] {
|
||||
subscription.setDuration(Subscription::Yearly);
|
||||
});
|
||||
|
||||
// Initialize user data
|
||||
QPushButton *germany = w.findChild<QPushButton *>("btnGermany");
|
||||
QPushButton *germany = w.findChild<QPushButton *>(u"btnGermany"_s);
|
||||
QObject::connect(germany, &QPushButton::clicked, &user, [&] {
|
||||
user.setCountry(User::Country::Germany);
|
||||
});
|
||||
QPushButton *finland = w.findChild<QPushButton *>("btnFinland");
|
||||
QPushButton *finland = w.findChild<QPushButton *>(u"btnFinland"_s);
|
||||
QObject::connect(finland, &QPushButton::clicked, &user, [&] {
|
||||
user.setCountry(User::Country::Finland);
|
||||
});
|
||||
QPushButton *norway = w.findChild<QPushButton *>("btnNorway");
|
||||
QPushButton *norway = w.findChild<QPushButton *>(u"btnNorway"_s);
|
||||
QObject::connect(norway, &QPushButton::clicked, &user, [&] {
|
||||
user.setCountry(User::Country::Norway);
|
||||
});
|
||||
|
||||
QSpinBox *ageSpinBox = w.findChild<QSpinBox *>("ageSpinBox");
|
||||
QSpinBox *ageSpinBox = w.findChild<QSpinBox *>(u"ageSpinBox"_s);
|
||||
QObject::connect(ageSpinBox, &QSpinBox::valueChanged, &user, [&](int value) {
|
||||
user.setAge(value);
|
||||
});
|
||||
|
||||
// Initialize price data
|
||||
QLabel *priceDisplay = w.findChild<QLabel *>("priceDisplay");
|
||||
QLabel *priceDisplay = w.findChild<QLabel *>(u"priceDisplay"_s);
|
||||
priceDisplay->setText(QString::number(subscription.price()));
|
||||
priceDisplay->setEnabled(subscription.isValid());
|
||||
|
||||
|
Reference in New Issue
Block a user