diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-19 15:18:12 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-10-19 16:29:48 +0200 |
commit | 91ab8c173d952e59f45f679a1a27d88b8606afd5 (patch) | |
tree | d930a21f909437650b9ecacadecd188d3f683810 /src/corelib/kernel | |
parent | 05078459de5dae65b9bb7cf2a1bc216528291648 (diff) |
QProperty: Add value() and setValue() to QBindable
This simplifies code that would otherwise need to use the setter and
getter in addition to the bindable.
Change-Id: Iec6510b4f578f5b223c63b3a0719257a0cf2463d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r-- | src/corelib/kernel/qproperty.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 5f1ef5bd83..21f1d78281 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -648,6 +648,20 @@ public: template <typename Functor> QPropertyBinding<T> setBinding(Functor f); #endif + + T value() const + { + T result; + if (iface) + iface->getter(data, &result); + return result; + } + + void setValue(const T &value) + { + if (iface) + iface->setter(data, &value); + } }; template<typename T> |