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>.
Loading...
Searching...
No Matches
QUntypedBindable Class Reference

\inmodule QtCore More...

#include <qproperty.h>

+ Inheritance diagram for QUntypedBindable:
+ Collaboration diagram for QUntypedBindable:

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< FunctoronValueChanged (Functor f) const
 Installs f as a change handler.
 
template<typename Functor >
QPropertyChangeHandler< Functorsubscribe (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

QUntypedPropertyDatadata = nullptr
 
const QtPrivate::QBindableInterfaceiface = nullptr
 

Friends

struct QUntypedBindablePrivate
 

Detailed Description

\inmodule QtCore

QUntypedBindable is a uniform interface over bindable properties like QProperty<T> and QObjectBindableProperty of any type T.

Since
6.0

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 678 of file qproperty.h.

Constructor & Destructor Documentation

◆ QUntypedBindable() [1/5]

constexpr QUntypedBindable::QUntypedBindable ( QUntypedPropertyData * d,
const QtPrivate::QBindableInterface * i )
inlineconstexprprotected

Definition at line 684 of file qproperty.h.

◆ QUntypedBindable() [2/5]

QUntypedBindable::QUntypedBindable ( QObject * obj,
const QMetaProperty & property,
const QtPrivate::QBindableInterface * i )
explicitprotected

◆ QUntypedBindable() [3/5]

QUntypedBindable::QUntypedBindable ( QObject * obj,
const char * property,
const QtPrivate::QBindableInterface * i )
explicitprotected

Definition at line 2560 of file qproperty.cpp.

References property, and qCWarning.

◆ QUntypedBindable() [4/5]

QUntypedBindable::QUntypedBindable ( )
constexprdefault

Default-constructs a QUntypedBindable.

It is in an invalid state.

See also
isValid()

◆ QUntypedBindable() [5/5]

template<typename Property >
template< typename Property > QUntypedBindable::QUntypedBindable ( Property * property)
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.

See also
isValid(), isReadOnly()

Definition at line 694 of file qproperty.h.

References iface, and Q_ASSERT.

Member Function Documentation

◆ addNotifier()

template<typename Functor >
template< typename Functor > QPropertyNotifier QUntypedBindable::addNotifier ( Functor f)
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.

See also
onValueChanged(), subscribe()

Definition at line 750 of file qproperty.h.

References observe().

+ Here is the call graph for this function:

◆ binding()

QUntypedPropertyBinding QUntypedBindable::binding ( ) const
inline

Returns the underlying property's binding if there is any, or a default constructed QUntypedPropertyBinding otherwise.

See also
hasBinding()

Definition at line 757 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasBinding()

bool QUntypedBindable::hasBinding ( ) const
inline

Returns true if the underlying property has a binding.

Definition at line 787 of file qproperty.h.

References binding(), and QUntypedPropertyBinding::isNull().

+ Here is the call graph for this function:

◆ isBindable()

bool QUntypedBindable::isBindable ( ) const
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.

See also
isReadOnly()

Definition at line 700 of file qproperty.h.

References QtPrivate::QBindableInterface::getBinding, and iface.

Referenced by binding().

+ Here is the caller graph for this function:

◆ isReadOnly()

bool QUntypedBindable::isReadOnly ( ) const
inline
Since
6.1

Returns true if the QUntypedBindable is read-only.

Definition at line 701 of file qproperty.h.

References iface, QtPrivate::QBindableInterface::setBinding, and QtPrivate::QBindableInterface::setObserver.

Referenced by setBinding().

+ Here is the caller graph for this function:

◆ isValid()

bool QUntypedBindable::isValid ( ) const
inline

Returns true if the QUntypedBindable is valid.

Methods called on an invalid QUntypedBindable generally have no effect, unless otherwise noted.

Definition at line 699 of file qproperty.h.

◆ makeBinding()

QUntypedPropertyBinding QUntypedBindable::makeBinding ( const QPropertyBindingSourceLocation & location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
inline

Creates a binding returning the underlying properties' value, using a specified source location.

Definition at line 703 of file qproperty.h.

References iface, and QtPrivate::QBindableInterface::makeBinding.

Referenced by QBindable< T >::makeBinding().

+ Here is the caller graph for this function:

◆ metaType()

QMetaType QUntypedBindable::metaType ( ) const
inline
Since
6.2

Returns the metatype of the property from which the QUntypedBindable was created. If the bindable is invalid, an invalid metatype will be returned.

See also
isValid() !
QUntypedPropertyBinding::valueMetaType()

Definition at line 792 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().

+ Here is the caller graph for this function:

◆ observe()

void QUntypedBindable::observe ( QPropertyObserver * observer) const
inline

Installs the observer on the underlying property.

Definition at line 723 of file qproperty.h.

References iface, QtPrivate::BindableWarnings::InvalidInterface, QtPrivate::BindableWarnings::printUnsuitableBindableWarning(), and QtPrivate::QBindableInterface::setObserver.

Referenced by addNotifier(), and onValueChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ onValueChanged()

template<typename Functor >
template< typename Functor > QPropertyChangeHandler< Functor > QUntypedBindable::onValueChanged ( Functor f) const
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.

See also
onValueChanged(), subscribe()

Definition at line 735 of file qproperty.h.

References observe().

Referenced by subscribe().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setBinding()

bool QUntypedBindable::setBinding ( const QUntypedPropertyBinding & binding)
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.

Returns
true when the binding was successfully set.

!

See also
QUntypedPropertyBinding::valueMetaType()

Definition at line 768 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ subscribe()

template<typename Functor >
template< typename Functor > QPropertyChangeHandler< Functor > QUntypedBindable::subscribe ( Functor f) const
inline

Behaves like a call to f followed by onValueChanged(f),.

See also
onValueChanged()

Definition at line 743 of file qproperty.h.

References onValueChanged().

+ Here is the call graph for this function:

◆ takeBinding()

QUntypedPropertyBinding QUntypedBindable::takeBinding ( )
inline

Removes the currently set binding from the property and returns it.

Returns a default-constructed QUntypedPropertyBinding if no binding is set.

Since
6.1

Definition at line 708 of file qproperty.h.

References binding(), QtPrivate::QBindableInterface::getBinding, iface, and QtPrivate::QBindableInterface::setBinding.

Referenced by QQmlObjectCreator::finalize(), QQmlAnyBinding::removeBindingFrom(), QBindable< T >::takeBinding(), and QQmlAnyBinding::takeFrom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ QUntypedBindablePrivate

friend struct QUntypedBindablePrivate
friend

Definition at line 680 of file qproperty.h.

Member Data Documentation

◆ data

QUntypedPropertyData* QUntypedBindable::data = nullptr
protected

Definition at line 682 of file qproperty.h.

Referenced by QUntypedBindablePrivate::getPropertyData().

◆ iface


The documentation for this class was generated from the following files: