![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtCore More...
#include <qproperty.h>
Public Member Functions | |
constexpr | QUntypedBindable ()=default |
Default-constructs a QUntypedBindable. | |
template<typename Property > | |
QUntypedBindable (Property *p) | |
Constructs a QUntypedBindable from the property property. | |
bool | isValid () const |
Returns true if the QUntypedBindable is valid. | |
bool | isBindable () const |
bool | isReadOnly () const |
QUntypedPropertyBinding | makeBinding (const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION) const |
Creates a binding returning the underlying properties' value, using a specified source location. | |
QUntypedPropertyBinding | takeBinding () |
Removes the currently set binding from the property and returns it. | |
void | observe (QPropertyObserver *observer) const |
template<typename Functor > | |
QPropertyChangeHandler< Functor > | onValueChanged (Functor f) const |
Installs f as a change handler. | |
template<typename Functor > | |
QPropertyChangeHandler< Functor > | subscribe (Functor f) const |
Behaves like a call to f followed by onValueChanged(f) ,. | |
template<typename Functor > | |
QPropertyNotifier | addNotifier (Functor f) |
Installs f as a change handler. | |
QUntypedPropertyBinding | binding () const |
Returns the underlying property's binding if there is any, or a default constructed QUntypedPropertyBinding otherwise. | |
bool | setBinding (const QUntypedPropertyBinding &binding) |
Sets the underlying property's binding to binding. | |
bool | hasBinding () const |
Returns true if the underlying property has a binding. | |
QMetaType | metaType () const |
Protected Member Functions | |
constexpr | QUntypedBindable (QUntypedPropertyData *d, const QtPrivate::QBindableInterface *i) |
Q_CORE_EXPORT | QUntypedBindable (QObject *obj, const QMetaProperty &property, const QtPrivate::QBindableInterface *i) |
Q_CORE_EXPORT | QUntypedBindable (QObject *obj, const char *property, const QtPrivate::QBindableInterface *i) |
Protected Attributes | |
QUntypedPropertyData * | data = nullptr |
const QtPrivate::QBindableInterface * | iface = nullptr |
Friends | |
struct | QUntypedBindablePrivate |
\inmodule QtCore
QUntypedBindable is a uniform interface over bindable properties like QProperty<T>
and QObjectBindableProperty
of any type T
.
QUntypedBindable is a fully type-erased generic interface to wrap bindable properties. You can use it to interact with properties without knowing their type nor caring what kind of bindable property they are (e.g. QProperty or QObjectBindableProperty). For most use cases, using QBindable<T> (which is generic over the property implementation but has a fixed type) should be preferred.
Definition at line 676 of file qproperty.h.
|
inlineconstexprprotected |
Definition at line 682 of file qproperty.h.
|
explicitprotected |
Definition at line 2515 of file qproperty.cpp.
References QMetaProperty::bindable(), QObjectPrivate::connect(), Qt::DirectConnection, QObjectPrivate::get(), QObjectPrivate::getPropertyAdaptorSlotObject(), QMetaProperty::hasNotifySignal(), iface, QMetaProperty::isBindable(), QMetaProperty::isValid(), QMetaProperty::metaType(), QtPrivate::QBindableInterface::metaType, QMetaProperty::name(), QMetaType::name(), QMetaProperty::notifySignalIndex(), QMetaProperty::propertyIndex(), Q_ASSERT, and qCWarning.
|
explicitprotected |
Definition at line 2567 of file qproperty.cpp.
|
constexprdefault |
|
inline |
Constructs a QUntypedBindable from the property property.
If Property is const, the QUntypedBindable will be read only. If property is null, the QUntypedBindable will be invalid.
Definition at line 692 of file qproperty.h.
|
inline |
Installs f as a change handler.
Whenever the underlying property changes, f will be called, as long as the returned QPropertyNotifier
and the property are kept alive.
This method is in some cases easier to use than onValueChanged(), as the returned object is not a template. It can therefore more easily be stored, e.g. as a member in a class.
Definition at line 748 of file qproperty.h.
References observe().
|
inline |
Returns the underlying property's binding if there is any, or a default constructed QUntypedPropertyBinding otherwise.
Definition at line 755 of file qproperty.h.
References QtPrivate::QBindableInterface::getBinding, iface, isBindable(), QtPrivate::BindableWarnings::NonBindableInterface, and QtPrivate::BindableWarnings::printUnsuitableBindableWarning().
Referenced by BindingFixer::BindingFixer(), QBindable< T >::binding(), hasBinding(), QQmlAnyBinding::ofProperty(), QQmlAnyBinding::ofProperty(), setBinding(), and takeBinding().
|
inline |
Returns true
if the underlying property has a binding.
Definition at line 785 of file qproperty.h.
References binding(), and QUntypedPropertyBinding::isNull().
Referenced by Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(), and QQuickBehavior::setTarget().
|
inline |
Returns true if the underlying property's binding can be queried with binding() and, if not read-only, changed with setBinding. Only QObjectComputedProperty currently leads to this method returning false.
Definition at line 698 of file qproperty.h.
References QtPrivate::QBindableInterface::getBinding, and iface.
Referenced by binding().
|
inline |
Returns true if the QUntypedBindable is read-only.
Definition at line 699 of file qproperty.h.
References iface, QtPrivate::QBindableInterface::setBinding, and QtPrivate::QBindableInterface::setObserver.
Referenced by setBinding().
|
inline |
Returns true if the QUntypedBindable is valid.
Methods called on an invalid QUntypedBindable generally have no effect, unless otherwise noted.
Definition at line 697 of file qproperty.h.
|
inline |
Creates a binding returning the underlying properties' value, using a specified source location.
Definition at line 701 of file qproperty.h.
References iface, and QtPrivate::QBindableInterface::makeBinding.
Referenced by QBindable< T >::makeBinding().
|
inline |
Returns the metatype of the property from which the QUntypedBindable was created. If the bindable is invalid, an invalid metatype will be returned.
Definition at line 790 of file qproperty.h.
References QtPrivate::QBindableInterface::getter, iface, QtPrivate::QBindableInterface::metaType, QtPrivate::QBindableInterface::MetaTypeAccessorFlag, and Q_ASSERT.
Referenced by QBindable< T >::QBindable(), QBindable< T >::setBinding(), and setBinding().
|
inline |
Installs the observer on the underlying property.
Definition at line 721 of file qproperty.h.
References iface, QtPrivate::BindableWarnings::InvalidInterface, QtPrivate::BindableWarnings::printUnsuitableBindableWarning(), and QtPrivate::QBindableInterface::setObserver.
Referenced by addNotifier(), and onValueChanged().
|
inline |
Installs f as a change handler.
Whenever the underlying property changes, f will be called, as long as the returned QPropertyChangeHandler
and the property are kept alive. On each value change, the handler is either called immediately, or deferred, depending on the context.
Definition at line 733 of file qproperty.h.
References observe().
Referenced by subscribe().
|
inline |
Sets the underlying property's binding to binding.
This does not have any effect if the QUntypedBindable is read-only, null or if binding's type does match the underlying property's type.
true
when the binding was successfully set.!
Definition at line 766 of file qproperty.h.
References binding(), iface, QtPrivate::BindableWarnings::InvalidInterface, QUntypedPropertyBinding::isNull(), isReadOnly(), metaType(), QtPrivate::BindableWarnings::printMetaTypeMismatch(), QtPrivate::BindableWarnings::printUnsuitableBindableWarning(), QtPrivate::BindableWarnings::ReadOnlyInterface, QtPrivate::QBindableInterface::setBinding, and QUntypedPropertyBinding::valueMetaType().
Referenced by QQmlObjectCreator::finalize(), QQmlAnyBinding::installOn(), and QV4::QObjectWrapper::setProperty().
|
inline |
Behaves like a call to f followed by onValueChanged(f)
,.
Definition at line 741 of file qproperty.h.
References onValueChanged().
|
inline |
Removes the currently set binding from the property and returns it.
Returns a default-constructed QUntypedPropertyBinding if no binding is set.
Definition at line 706 of file qproperty.h.
References binding(), QtPrivate::QBindableInterface::getBinding, iface, and QtPrivate::QBindableInterface::setBinding.
Referenced by QQmlObjectCreator::finalize(), QQmlAnyBinding::removeBindingFrom(), QQuickBehavior::setTarget(), QBindable< T >::takeBinding(), and QQmlAnyBinding::takeFrom().
|
friend |
Definition at line 678 of file qproperty.h.
|
protected |
Definition at line 680 of file qproperty.h.
Referenced by QUntypedBindablePrivate::getPropertyData().
|
protected |
Definition at line 681 of file qproperty.h.
Referenced by QBindable< T >::QBindable(), QUntypedBindable(), QUntypedBindable(), binding(), QUntypedBindablePrivate::getInterface(), isBindable(), isReadOnly(), makeBinding(), metaType(), observe(), QBindable< T >::setBinding(), setBinding(), QBindable< T >::setValue(), takeBinding(), and QBindable< T >::value().