Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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 679 of file qproperty.h.

Constructor & Destructor Documentation

◆ QUntypedBindable() [1/5]

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

Definition at line 685 of file qproperty.h.

References QUntypedBindable(), and iface.

Referenced by QUntypedBindable().

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

◆ QUntypedBindable() [2/5]

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

Definition at line 2515 of file qproperty.cpp.

References iface.

◆ QUntypedBindable() [3/5]

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

Definition at line 2567 of file qproperty.cpp.

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

References QUntypedBindable().

Referenced by QUntypedBindable().

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

Member Function Documentation

◆ addNotifier()

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

References isBindable(), QtPrivate::BindableWarnings::NonBindableInterface, and QtPrivate::BindableWarnings::printUnsuitableBindableWarning().

+ Here is the call graph for this function:

◆ hasBinding()

bool QUntypedBindable::hasBinding ( ) const
inline

Returns true if the underlying property has a binding.

Definition at line 788 of file qproperty.h.

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

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

References iface, 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 700 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 704 of file qproperty.h.

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

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

◆ observe()

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

Installs the observer on the underlying property.

Definition at line 724 of file qproperty.h.

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

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

References QPropertyChangeHandler< Functor >::QPropertyChangeHandler(), and observe().

+ Here is the call 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 769 of file qproperty.h.

References iface, QtPrivate::BindableWarnings::InvalidInterface, isReadOnly(), QtPrivate::BindableWarnings::printUnsuitableBindableWarning(), and QtPrivate::BindableWarnings::ReadOnlyInterface.

+ Here is the call graph for this function:

◆ subscribe()

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

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

References iface.

Friends And Related Symbol Documentation

◆ QUntypedBindablePrivate

friend struct QUntypedBindablePrivate
friend

Definition at line 681 of file qproperty.h.

Member Data Documentation

◆ data

QUntypedPropertyData* QUntypedBindable::data = nullptr
protected

Definition at line 683 of file qproperty.h.

◆ iface


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