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

#include <qproperty.h>

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

Public Member Functions

 QPropertyAlias (QProperty< T > *property)
 
template<typename Property , typename = typename Property::InheritsQUntypedPropertyData>
 QPropertyAlias (Property *property)
 
 QPropertyAlias (QPropertyAlias< T > *alias)
 
 QPropertyAlias (const QBindable< T > &property)
 
T value () const
 
 operator T () const
 
void setValue (const T &newValue)
 
QPropertyAlias< T > & operator= (const T &newValue)
 
QPropertyBinding< TsetBinding (const QPropertyBinding< T > &newBinding)
 
bool setBinding (const QUntypedPropertyBinding &newBinding)
 
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)
 
bool hasBinding () const
 
QPropertyBinding< Tbinding () const
 
QPropertyBinding< TtakeBinding ()
 
template<typename Functor >
QPropertyChangeHandler< FunctoronValueChanged (Functor f)
 
template<typename Functor >
QPropertyChangeHandler< Functorsubscribe (Functor f)
 
template<typename Functor >
QPropertyNotifier addNotifier (Functor f)
 
bool isValid () const
 
- Public Member Functions inherited from QPropertyObserver
constexpr QPropertyObserver ()=default
 
 QPropertyObserver (QPropertyObserver &&other) noexcept
 
QPropertyObserveroperator= (QPropertyObserver &&other) noexcept
 
 ~QPropertyObserver ()
 
template<typename Property , typename = typename Property::InheritsQUntypedPropertyData>
void setSource (const Property &property)
 
void setSource (const QtPrivate::QPropertyBindingData &property)
 

Additional Inherited Members

- Public Types inherited from QPropertyObserverBase
enum  ObserverTag { ObserverNotifiesBinding , ObserverNotifiesChangeHandler , ObserverIsPlaceholder , ObserverIsAlias }
 
- Protected Types inherited from QPropertyObserverBase
using ChangeHandler = void(*)(QPropertyObserver *, QUntypedPropertyData *)
 
- Protected Member Functions inherited from QPropertyObserver
 QPropertyObserver (ChangeHandler changeHandler)
 
 QPropertyObserver (QUntypedPropertyData *aliasedPropertyPtr)
 
QUntypedPropertyDataaliasedProperty () const
 

Detailed Description

template<typename T>
class QPropertyAlias< T >

\inmodule QtCore

Definition at line 829 of file qproperty.h.

Constructor & Destructor Documentation

◆ QPropertyAlias() [1/4]

template<typename T >
template< typename T > QPropertyAlias< T >::QPropertyAlias ( QProperty< T > *  property)
inline

Constructs a property alias for the given property.

Definition at line 835 of file qproperty.h.

Here is the call graph for this function:

◆ QPropertyAlias() [2/4]

template<typename T >
template<typename Property , typename = typename Property::InheritsQUntypedPropertyData>
QPropertyAlias< T >::QPropertyAlias ( Property *  property)
inline

Definition at line 844 of file qproperty.h.

Here is the call graph for this function:

◆ QPropertyAlias() [3/4]

template<typename T >
template< typename T > explicit QPropertyAlias< T >::QPropertyAlias ( QPropertyAlias< T > *  alias)
inline

Constructs a property alias for the property aliased by alias.

Definition at line 852 of file qproperty.h.

Here is the call graph for this function:

◆ QPropertyAlias() [4/4]

template<typename T >
QPropertyAlias< T >::QPropertyAlias ( const QBindable< T > &  property)
inline

Definition at line 860 of file qproperty.h.

Here is the call graph for this function:

Member Function Documentation

◆ addNotifier()

template<typename T >
template<typename Functor >
template< typename T > template< typename Functor > QPropertyNotifier QPropertyAlias< T >::addNotifier ( Functor  f)
inline

Subscribes the given functor f as a callback that is called whenever the value of the aliased property changes.

The callback f is expected to be a type that has a plain call operator () without any parameters. This means that you can provide a C++ lambda expression, a std::function or even a custom struct with a call operator.

The returned property change handler object keeps track of the subscription. When it goes out of scope, the callback is unsubscribed.

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

Here is the call graph for this function:

◆ binding()

template<typename T >
template< typename T > QPropertyBinding< T > QPropertyAlias< T >::binding ( ) const
inline

Returns the binding expression that is associated with the aliased property. A default constructed QPropertyBinding<T> will be returned if no such association exists.

Definition at line 918 of file qproperty.h.

Here is the call graph for this function:

◆ hasBinding()

template<typename T >
template< typename T > bool QPropertyAlias< T >::hasBinding ( ) const
inline

Returns true if the aliased property is associated with a binding; false otherwise.

Definition at line 913 of file qproperty.h.

Here is the call graph for this function:

◆ isValid()

template<typename T >
template< typename T > bool QPropertyAlias< T >::isValid ( ) const
inline

Returns true if the aliased property still exists; false otherwise.

If the aliased property doesn't exist, all other method calls are ignored.

Definition at line 946 of file qproperty.h.

Here is the call graph for this function:

◆ onValueChanged()

template<typename T >
template<typename Functor >
template< typename T > template< typename Functor > QPropertyChangeHandler< T, Functor > QPropertyAlias< T >::onValueChanged ( Functor  f)
inline

Registers the given functor f as a callback that shall be called whenever the value of the aliased property changes. On each value change, the handler is either called immediately, or deferred, depending on the context.

The callback f is expected to be a type that has a plain call operator () without any parameters. This means that you can provide a C++ lambda expression, a std::function or even a custom struct with a call operator.

The returned property change handler object keeps track of the registration. When it goes out of scope, the callback is de-registered.

Definition at line 929 of file qproperty.h.

Here is the call graph for this function:

◆ operator T()

template<typename T >
template< typename T > QPropertyAlias< T >::operator T ( ) const
inline

Returns the value of the aliased property. This may evaluate a binding expression that is tied to the property, before returning the value.

Definition at line 876 of file qproperty.h.

Here is the call graph for this function:

◆ operator=()

template<typename T >
template< typename T > QPropertyAlias< T > & QPropertyAlias< T >::operator= ( const T newValue)
inline

Assigns newValue to the aliased property and returns a reference to this QPropertyAlias.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Assigns newValue to the aliased property and returns a reference to this QPropertyAlias.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Associates the value of the aliased property with the provided newBinding expression and returns a reference to this alias. The first time the property value is read, either from the property itself or from any alias, the binding is evaluated. Whenever a dependency of the binding changes, the binding will be re-evaluated the next time the value of this property is read.

Definition at line 884 of file qproperty.h.

Here is the call graph for this function:

◆ setBinding() [1/3]

template<typename T >
template< typename T > QPropertyBinding< T > QPropertyAlias< T >::setBinding ( const QPropertyBinding< T > &  newBinding)
inline

Associates the value of the aliased property with the provided newBinding expression and returns any previous binding the associated with the aliased property. The first time the property value is read, either from the property itself or from any alias, the binding is evaluated. Whenever a dependency of the binding changes, the binding will be re-evaluated the next time the value of this property is read.

Returns any previous binding associated with the property, or a default-constructed QPropertyBinding<T>.

Definition at line 890 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 >
template< typename T > QPropertyBinding< T > bool QPropertyAlias< T >::setBinding ( const QUntypedPropertyBinding newBinding)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Associates the value of the aliased property with the provided newBinding expression. The first time the property value is read, either from the property itself or from any alias, the binding is evaluated. Whenever a dependency of the binding changes, the binding will be re-evaluated the next time the value of this property is read.

Returns true if the type of this property is the same as the type the binding function returns; false otherwise.

Definition at line 895 of file qproperty.h.

Here is the call graph for this function:

◆ setBinding() [3/3]

template<typename T >
template<typename Functor >
QPropertyBinding<T> QPropertyAlias< 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 902 of file qproperty.h.

Here is the call graph for this function:

◆ setValue()

template<typename T >
template< typename T > void QPropertyAlias< T >::setValue ( const T newValue)
inline

Assigns newValue to the aliased property and removes the property's associated binding, if present.

Definition at line 878 of file qproperty.h.

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

◆ subscribe()

template<typename T >
template<typename Functor >
template< typename T > template< typename Functor > QPropertyChangeHandler< T, Functor > QPropertyAlias< T >::subscribe ( Functor  f)
inline

Subscribes the given functor f as a callback that is called immediately and whenever the value of the aliased property changes in the future. On each value change, the handler is either called immediately, or deferred, depending on the context.

The callback f is expected to be a type that has a plain call operator () without any parameters. This means that you can provide a C++ lambda expression, a std::function or even a custom struct with a call operator.

The returned property change handler object keeps track of the subscription. When it goes out of scope, the callback is unsubscribed.

Definition at line 935 of file qproperty.h.

Here is the call graph for this function:

◆ takeBinding()

template<typename T >
template< typename T > QPropertyBinding< T > QPropertyAlias< T >::takeBinding ( )
inline

Disassociates the binding expression from the aliased property and returns it. After calling this function, the value of the property will only change if you assign a new value to it, or when a new binding is set.

Definition at line 923 of file qproperty.h.

Here is the call graph for this function:

◆ value()

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

Returns the value of the aliased property. This may evaluate a binding expression that is tied to the property, before returning the value.

Definition at line 868 of file qproperty.h.

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

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