Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
|
\inmodule QtCore More...
#include <qproperty.h>
Public Member Functions | |
QBindable (const QUntypedBindable &b) | |
QBindable (QObject *obj, const QMetaProperty &property) | |
See \l QBindable::QBindable(QObject *obj, const char *property) | |
QBindable (QObject *obj, const char *property) | |
Constructs a QBindable for the \l Q_PROPERTY property on obj. | |
QPropertyBinding< T > | makeBinding (const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION) const |
Constructs a binding evaluating to the underlying property's value, using a specified source location. | |
QPropertyBinding< T > | binding () const |
Returns the currently set binding of the underlying property. | |
QPropertyBinding< T > | takeBinding () |
Removes the currently set binding of the underlying property and returns it. | |
QPropertyBinding< T > | setBinding (const QPropertyBinding< T > &binding) |
Sets the underlying property's binding to binding. | |
template<typename Functor > | |
QPropertyBinding< T > | setBinding (Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, std::enable_if_t< std::is_invocable_v< Functor > > *=nullptr) |
T | value () const |
Returns the underlying property's current value. | |
void | setValue (const T &value) |
Sets the underlying property's value to value. | |
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) |
constexpr | QUntypedBindable ()=default |
Default-constructs a QUntypedBindable. | |
template<typename Property > | |
QUntypedBindable (Property *p) | |
Constructs a QUntypedBindable from the property property. | |
bool | setBinding (const QUntypedPropertyBinding &binding) |
Sets the underlying property's binding to binding. | |
Public Member Functions inherited from QUntypedBindable | |
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 |
Friends | |
template<typename U > | |
class | QPropertyAlias |
Additional Inherited Members | |
Protected Member Functions inherited from QUntypedBindable | |
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 inherited from QUntypedBindable | |
QUntypedPropertyData * | data = nullptr |
const QtPrivate::QBindableInterface * | iface = nullptr |
\inmodule QtCore
QBindable is a wrapper class around binding-enabled properties. It allows type-safe operations while abstracting the differences between the various property classes away. \inherits QUntypedBindable
QBindable<T> helps to integrate Qt's traditional Q_PROPERTY with \l {Qt Bindable Properties}{binding-enabled} properties. If a property is backed by a QProperty, QObjectBindableProperty or QObjectComputedProperty, you can add BINDABLE
bindablePropertyName to the Q_PROPERTY declaration, where bindablePropertyName is a function returning an instance of QBindable constructed from the QProperty. The returned QBindable allows users of the property to set and query bindings of the property, without having to know the exact kind of binding-enabled property used.
Definition at line 810 of file qproperty.h.
|
inlineexplicit |
Definition at line 819 of file qproperty.h.
References QUntypedBindable::iface, and QUntypedBindable::metaType().
|
inlineexplicit |
See \l QBindable::QBindable(QObject *obj, const char *property)
Definition at line 827 of file qproperty.h.
|
inlineexplicit |
Constructs a QBindable for the \l Q_PROPERTY property on obj.
The property must have a notify signal but does not need to have BINDABLE
in its Q_PROPERTY
definition, so even binding unaware {Q_PROPERTY}s
can be bound or used in binding expressions. You must use QBindable::value()
in binding expressions instead of the normal property READ
function (or MEMBER
) to enable dependency tracking if the property is not BINDABLE
. When binding using a lambda, you may prefer to capture the QBindable by value to avoid the cost of calling this constructor in the binding expression. This constructor should not be used to implement BINDABLE
for a Q_PROPERTY, as the resulting Q_PROPERTY will not support dependency tracking. To make a property that is usable directly without reading through a QBindable use \l QProperty or \l QObjectBindableProperty.
Definition at line 830 of file qproperty.h.
|
inline |
Returns the currently set binding of the underlying property.
If the property does not have a binding, the returned QPropertyBinding<T>
will be invalid.
Definition at line 837 of file qproperty.h.
References QUntypedBindable::binding().
Referenced by QBindable< T >::setBinding().
|
inline |
Constructs a binding evaluating to the underlying property's value, using a specified source location.
Definition at line 833 of file qproperty.h.
References QUntypedBindable::makeBinding().
|
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 694 of file qproperty.h.
|
explicit |
Definition at line 689 of file qproperty.cpp.
|
explicit |
Definition at line 688 of file qproperty.cpp.
|
inlineconstexpr |
Definition at line 684 of file qproperty.h.
|
inline |
Sets the underlying property's binding to binding.
Does nothing if the QBindable is read-only or invalid.
Definition at line 848 of file qproperty.h.
References QBindable< T >::binding(), QUntypedBindable::iface, QtPrivate::BindableWarnings::InvalidInterface, QUntypedBindable::metaType(), QtPrivate::BindableWarnings::printUnsuitableBindableWarning(), Q_ASSERT, QtPrivate::BindableWarnings::ReadOnlyInterface, and QtPrivate::QBindableInterface::setBinding.
Referenced by QBindable< T >::setBinding().
|
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 768 of file qproperty.h.
|
inline |
Definition at line 864 of file qproperty.h.
References Qt::makePropertyBinding(), and QBindable< T >::setBinding().
|
inline |
Sets the underlying property's value to value.
This removes any currenltly set binding from it. This function has no effect if the QBindable is read-only or invalid.
Definition at line 885 of file qproperty.h.
References QUntypedBindable::iface, and QtPrivate::QBindableInterface::setter.
|
inline |
Removes the currently set binding of the underlying property and returns it.
If the property does not have a binding, the returned QPropertyBinding<T>
will be invalid.
Definition at line 842 of file qproperty.h.
References QUntypedBindable::takeBinding().
Returns the underlying property's current value.
If the QBindable is invalid, a default constructed T
is returned.
Definition at line 875 of file qproperty.h.
References QtPrivate::QBindableInterface::getter, and QUntypedBindable::iface.
Definition at line 813 of file qproperty.h.