QtBase  v6.3.1
Public Member Functions | Friends | List of all members
QBindable< T > Class Template Reference

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. More...

#include <qproperty.h>

Inheritance diagram for QBindable< T >:
Inheritance graph
[legend]
Collaboration diagram for QBindable< T >:
Collaboration graph
[legend]

Public Member Functions

 QBindable (const QUntypedBindable &b)
 
QPropertyBinding< TmakeBinding (const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
 
QPropertyBinding< Tbinding () const
 
QPropertyBinding< TtakeBinding ()
 
QPropertyBinding< TsetBinding (const QPropertyBinding< T > &binding)
 
template<typename Functor >
QPropertyBinding< TsetBinding (Functor &&f, const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION, std::enable_if_t< std::is_invocable_v< Functor >> *=nullptr)
 
T value () const
 
void setValue (const T &value)
 
constexpr QUntypedBindable (QUntypedPropertyData *d, const QtPrivate::QBindableInterface *i)
 
constexpr QUntypedBindable ()=default
 
template<typename Property >
 QUntypedBindable (Property *p)
 
bool setBinding (const QUntypedPropertyBinding &binding)
 
- Public Member Functions inherited from QUntypedBindable
constexpr QUntypedBindable ()=default
 
template<typename Property >
 QUntypedBindable (Property *p)
 
bool isValid () const
 
bool isBindable () const
 
bool isReadOnly () const
 
QUntypedPropertyBinding makeBinding (const QPropertyBindingSourceLocation &location=QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
 
QUntypedPropertyBinding takeBinding ()
 
void observe (QPropertyObserver *observer) const
 
template<typename Functor >
QPropertyChangeHandler< FunctoronValueChanged (Functor f) const
 
template<typename Functor >
QPropertyChangeHandler< Functorsubscribe (Functor f) const
 
template<typename Functor >
QPropertyNotifier addNotifier (Functor f)
 
QUntypedPropertyBinding binding () const
 
bool setBinding (const QUntypedPropertyBinding &binding)
 
bool hasBinding () const
 
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)
 
- Protected Attributes inherited from QUntypedBindable
QUntypedPropertyDatadata = nullptr
 
const QtPrivate::QBindableInterfaceiface = nullptr
 

Detailed Description

template<typename T>
class QBindable< T >

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.

\inmodule QtCore

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.

See also
QMetaProperty::isBindable, QProperty, QObjectBindableProperty, QObjectComputedProperty, {Qt Bindable Properties}

Definition at line 752 of file qproperty.h.

Constructor & Destructor Documentation

◆ QBindable()

template<typename T >
QBindable< T >::QBindable ( const QUntypedBindable b)
inlineexplicit

Definition at line 761 of file qproperty.h.

Here is the call graph for this function:

Member Function Documentation

◆ binding()

template<typename T >
template< typename T > QPropertyBinding< T > QBindable< T >::binding ( ) const
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.

See also
setBinding, hasBinding !
QPropertyBinding::isValid()

Definition at line 773 of file qproperty.h.

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

◆ makeBinding()

template<typename T >
template< typename T > QPropertyBinding< T > QBindable< T >::makeBinding ( const QPropertyBindingSourceLocation location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
inline

Constructs a binding evaluating to the underlying property's value, using a specified source location.

Definition at line 769 of file qproperty.h.

Here is the call graph for this function:

◆ QUntypedBindable() [1/3]

template<typename T >
QUntypedBindable::QUntypedBindable
constexprdefault

Default-constructs a QUntypedBindable. It is in an invalid state.

See also
isValid()

◆ QUntypedBindable() [2/3]

template<typename T >
template<typename Property >
template< typename Property > QUntypedBindable::QUntypedBindable ( typename 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 636 of file qproperty.h.

◆ QUntypedBindable() [3/3]

template<typename T >
constexpr QUntypedBindable::QUntypedBindable
inlineconstexpr

Definition at line 629 of file qproperty.h.

◆ setBinding() [1/3]

template<typename T >
template< typename T > void QBindable< T >::setBinding ( const QPropertyBinding< T > &  binding)
inline

Sets the underlying property's binding to binding. Does nothing if the QBindable is read-only or invalid.

See also
binding, isReadOnly(), isValid() !
QPropertyBinding::isValid()

Definition at line 784 of file qproperty.h.

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

◆ setBinding() [2/3]

template<typename T >
bool QUntypedBindable::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.

Returns
true when the binding was successfully set.

!

See also
QUntypedPropertyBinding::valueMetaType()

Definition at line 710 of file qproperty.h.

Here is the caller graph for this function:

◆ setBinding() [3/3]

template<typename T >
template<typename Functor >
QPropertyBinding<T> QBindable< T >::setBinding ( Functor &&  f,
const QPropertyBindingSourceLocation location = QT_PROPERTY_DEFAULT_BINDING_LOCATION,
std::enable_if_t< std::is_invocable_v< Functor >> *  = nullptr 
)
inline

Definition at line 800 of file qproperty.h.

Here is the call graph for this function:

◆ setValue()

template<typename T >
template< typename T > void QBindable< T >::setValue ( const T value)
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.

See also
isValid(), isReadOnly(), setBinding()

Definition at line 821 of file qproperty.h.

◆ takeBinding()

template<typename T >
template< typename T > QPropertyBinding< T > QBindable< T >::takeBinding ( )
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.

See also
binding, setBinding, hasBinding !
QPropertyBinding::isValid()

Definition at line 778 of file qproperty.h.

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

◆ value()

template<typename T >
template< typename T > T QBindable< T >::value ( ) const
inline

Returns the underlying property's current value. If the QBindable is invalid, a default constructed T is returned.

See also
isValid()

Definition at line 811 of file qproperty.h.

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ QPropertyAlias

template<typename T >
template<typename U >
friend class QPropertyAlias
friend

Definition at line 755 of file qproperty.h.


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