diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-01-22 11:06:52 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-01-27 15:01:56 +0100 |
commit | 0f4d512dc46cb9d24b58083efdc1fa4631bdbec4 (patch) | |
tree | ca82bee7dc0721e208ad73a2fb6ca2db849bc31e /src/corelib/kernel/qproperty.cpp | |
parent | f07c6f52ac4e336bd49c5d3cdaf89803460ba3bf (diff) |
Q(Untyped)Bindable: add takeBinding method
We missed takeBinding as a supported operation on Q(Untyped)Bindable.
To avoid adding version checks to code dealing with QBindableInterface,
we simply synthesize takeBinding as a combination of binding to retrieve
the binding and setBinding with a default-constructed
QUntypedPropertyBinding.
Change-Id: I43803a0dfe210353d0235f0373d2257f75ffe534
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/kernel/qproperty.cpp')
-rw-r--r-- | src/corelib/kernel/qproperty.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/corelib/kernel/qproperty.cpp b/src/corelib/kernel/qproperty.cpp index 342a3d34eb..90df159e88 100644 --- a/src/corelib/kernel/qproperty.cpp +++ b/src/corelib/kernel/qproperty.cpp @@ -788,10 +788,19 @@ QString QPropertyBindingError::description() const */ /*! + \fn QUntypedPropertyBinding QUntypedBindable::takeBinding() + + Removes the currently set binding from the property and returns it. + Returns a default-constructed QUntypedPropertyBinding if no binding is set. + + \since 6.1 +*/ + +/*! \fn bool QUntypedBindable::setBinding(const QUntypedPropertyBinding &binding) Sets the underlying property's binding to \a binding. This does not have any effect - if the QUntypedBindable is read-only, invalid or if \a binding's type does match the + if the QUntypedBindable is read-only, null or if \a binding's type does match the underlying property's type. \sa QUntypedPropertyBinding::valueMetaType() @@ -842,6 +851,16 @@ QString QPropertyBindingError::description() const */ /*! + \fn template <typename T> QPropertyBinding<T> QBindable<T>::takeBinding() + + Removes the currently set binding of the underlying property and returns it. + If the property does not have a binding, the returned \c QPropertyBinding<T> will be invalid. + + \sa setBinding, getBinding, QPropertyBinding<T>::isValid(), hasBinding +*/ + + +/*! \fn template <typename T> void QBindable<T>::setBinding(const QPropertyBinding<T> &binding) Sets the underlying property's binding to \a binding. Does nothing if the QBindable is |