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
QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter > Class Template Reference

\macro Q_OBJECT_BINDABLE_PROPERTY(containingClass, type, name, signal) More...

#include <qproperty_p.h>

+ Inheritance diagram for QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >:
+ Collaboration diagram for QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >:

Public Types

using value_type = typename QPropertyData<T>::value_type
 
using parameter_type = typename QPropertyData<T>::parameter_type
 
using arrow_operator_result = typename QPropertyData<T>::arrow_operator_result
 
- Public Types inherited from QPropertyData< T >
using value_type = T
 
using parameter_type = std::conditional_t<UseReferences, const T &, T>
 
using rvalue_ref = typename std::conditional_t<UseReferences, T &&, DisableRValueRefs>
 
using arrow_operator_result
 

Public Member Functions

 QObjectCompatProperty ()=default
 
 QObjectCompatProperty (const T &initialValue)
 
 QObjectCompatProperty (T &&initialValue)
 
parameter_type value () const
 
arrow_operator_result operator-> () const
 
parameter_type operator* () const
 
 operator parameter_type () const
 
void setValue (parameter_type t)
 
QObjectCompatPropertyoperator= (parameter_type newValue)
 
QPropertyBinding< T > setBinding (const QPropertyBinding< T > &newBinding)
 
bool setBinding (const QUntypedPropertyBinding &newBinding)
 
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)
 
bool hasBinding () const
 
void removeBindingUnlessInWrapper ()
 
void notify ()
 
QPropertyBinding< T > binding () const
 
QPropertyBinding< T > takeBinding ()
 
template<typename Functor >
QPropertyChangeHandler< FunctoronValueChanged (Functor f)
 
template<typename Functor >
QPropertyChangeHandler< Functorsubscribe (Functor f)
 
template<typename Functor >
QPropertyNotifier addNotifier (Functor f)
 
QtPrivate::QPropertyBindingDatabindingData () const
 
- Public Member Functions inherited from QPropertyData< T >
 QPropertyData ()=default
 
 QPropertyData (parameter_type t)
 
 QPropertyData (rvalue_ref t)
 
 ~QPropertyData ()=default
 
parameter_type valueBypassingBindings () const
 Returns the data stored in this property.
 
void setValueBypassingBindings (parameter_type v)
 Sets the data value stored in this property to v.
 
void setValueBypassingBindings (rvalue_ref v)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Sets the data value stored in this property to v.
 

Friends

template<typename Property , typename >
class QtPrivate::QBindableInterfaceForProperty
 

Additional Inherited Members

- Protected Attributes inherited from QPropertyData< T >
val = T()
 
- Static Protected Attributes inherited from QPropertyData< T >
static constexpr bool UseReferences = !(std::is_arithmetic_v<T> || std::is_enum_v<T> || std::is_pointer_v<T>)
 

Detailed Description

template<typename Class, typename T, auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
class QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >

\macro Q_OBJECT_BINDABLE_PROPERTY(containingClass, type, name, signal)

Since
6.0

Declares a \l QObjectBindableProperty inside containingClass of type type with name name. If the optional argument signal is given, this signal will be emitted when the property is marked dirty.

See also
{Qt's Property System}, {Qt Bindable Properties}

\macro Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(containingClass, type, name, initialvalue, signal)

Since
6.0

Declares a \l QObjectBindableProperty inside containingClass of type type with name name which is initialized to initialvalue. If the optional argument signal is given, this signal will be emitted when the property is marked dirty.

See also
{Qt's Property System}, {Qt Bindable Properties}

\inmodule QtCore

The QObjectCompatProperty class is a template class to help port old properties to the bindable property system.

Since
6.0

QObjectCompatProperty is a generic container that holds an instance of T and behaves mostly like QProperty, just like QObjectBindableProperty. It's one of the Qt internal classes implementing \l {Qt Bindable Properties}. Like QObjectBindableProperty, QObjectCompatProperty stores its management data structure in the surrounding QObject. The last template parameter specifies a method (of the owning class) to be called when the property is changed through the binding. This is usually a setter.

As explained in \l {Qt Bindable Properties}, getters and setters for bindable properties have to be almost trivial to be correct. However, in legacy code, there is often complex logic in the setter. QObjectCompatProperty is a helper to port these properties to the bindable property system.

With QObjectCompatProperty, the same rules as described in \l {Bindable Property Getters and Setters} hold for the getter. For the setter, the rules are different. It remains that every possible code path in the setter must write to the underlying QObjectCompatProperty, otherwise calling the setter might not remove a pre-existing binding, as it should. However, as QObjectCompatProperty will call the setter on every change, the setter is allowed to contain code like updating class internals or emitting signals. Every write to the QObjectCompatProperty has to be analyzed carefully to comply with the rules given in \l {Writing to a Bindable Property}.

Some of the pre-existing Qt classes (for example, \l QAbstractProxyModel) have properties with virtual setters. Special care must be taken when making such properties bindable.

For the binding to work properly, the property must be correctly handled in all reimplemented methods of each derived class.

Unless the derived class has access to the underlying property object, the base implementation must be called for the binding to work correctly.

If the derived class can directly access the property instance, there is no need to explicitly call the base implementation, but the property's value must be correctly updated.

Refer to \l {Bindable Properties with Virtual Setters and Getters} for more details.

In both cases the expected behavior must be documented in the property's documentation, so that users can correctly override the setter.

Properties for which these conditions cannot be met should not be made bindable.

See also
Q_OBJECT_COMPAT_PROPERTY, QObjectBindableProperty, {Qt's Property System}, {Qt Bindable Properties}

Definition at line 508 of file qproperty_p.h.

Member Typedef Documentation

◆ arrow_operator_result

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
using QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::arrow_operator_result = typename QPropertyData<T>::arrow_operator_result

Definition at line 560 of file qproperty_p.h.

◆ parameter_type

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
using QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::parameter_type = typename QPropertyData<T>::parameter_type

Definition at line 559 of file qproperty_p.h.

◆ value_type

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
using QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::value_type = typename QPropertyData<T>::value_type

Definition at line 558 of file qproperty_p.h.

Constructor & Destructor Documentation

◆ QObjectCompatProperty() [1/3]

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::QObjectCompatProperty ( )
default

◆ QObjectCompatProperty() [2/3]

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::QObjectCompatProperty ( const T & initialValue)
inlineexplicit

Definition at line 563 of file qproperty_p.h.

◆ QObjectCompatProperty() [3/3]

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::QObjectCompatProperty ( T && initialValue)
inlineexplicit

Definition at line 564 of file qproperty_p.h.

Member Function Documentation

◆ addNotifier()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
template<typename Functor >
QPropertyNotifier QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::addNotifier ( Functor f)
inline

Definition at line 717 of file qproperty_p.h.

◆ binding()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
QPropertyBinding< T > QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::binding ( ) const
inline

Definition at line 690 of file qproperty_p.h.

References QBindingStorage::bindingData(), and qGetBindingStorage().

+ Here is the call graph for this function:

◆ bindingData()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
QtPrivate::QPropertyBindingData & QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::bindingData ( ) const
inline

Definition at line 723 of file qproperty_p.h.

References qGetBindingStorage(), and storage.

+ Here is the call graph for this function:

◆ hasBinding()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
bool QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::hasBinding ( ) const
inline

Definition at line 643 of file qproperty_p.h.

References QtPrivate::QPropertyBindingData::binding(), QBindingStorage::bindingData(), and qGetBindingStorage().

+ Here is the call graph for this function:

◆ notify()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
void QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::notify ( )
inline

Definition at line 658 of file qproperty_p.h.

References d, qGetBindingStorage(), and storage.

+ Here is the call graph for this function:

◆ onValueChanged()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
template<typename Functor >
QPropertyChangeHandler< Functor > QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::onValueChanged ( Functor f)
inline

Definition at line 702 of file qproperty_p.h.

◆ operator parameter_type()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::operator parameter_type ( ) const
inline

Definition at line 592 of file qproperty_p.h.

◆ operator*()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
parameter_type QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::operator* ( ) const
inline

Definition at line 587 of file qproperty_p.h.

◆ operator->()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
arrow_operator_result QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::operator-> ( ) const
inline

Definition at line 575 of file qproperty_p.h.

◆ operator=()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
QObjectCompatProperty & QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::operator= ( parameter_type newValue)
inline

Definition at line 608 of file qproperty_p.h.

References setValue().

+ Here is the call graph for this function:

◆ removeBindingUnlessInWrapper()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
void QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::removeBindingUnlessInWrapper ( )
inline

Definition at line 648 of file qproperty_p.h.

References qGetBindingStorage(), and storage.

+ Here is the call graph for this function:

◆ setBinding() [1/3]

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
QPropertyBinding< T > QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::setBinding ( const QPropertyBinding< T > & newBinding)
inline

Definition at line 614 of file qproperty_p.h.

References QBindingStorage::bindingData(), and qGetBindingStorage().

+ Here is the call graph for this function:

◆ setBinding() [2/3]

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
bool QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::setBinding ( const QUntypedPropertyBinding & newBinding)
inline

Definition at line 622 of file qproperty_p.h.

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

+ Here is the call graph for this function:

◆ setBinding() [3/3]

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
template<typename Functor >
QPropertyBinding< T > QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::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 632 of file qproperty_p.h.

References Qt::makePropertyBinding().

+ Here is the call graph for this function:

◆ setValue()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
void QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::setValue ( parameter_type t)
inline

Definition at line 597 of file qproperty_p.h.

References qGetBindingStorage(), and storage.

+ Here is the call graph for this function:

◆ subscribe()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
template<typename Functor >
QPropertyChangeHandler< Functor > QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::subscribe ( Functor f)
inline

Definition at line 709 of file qproperty_p.h.

◆ takeBinding()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
QPropertyBinding< T > QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::takeBinding ( )
inline

Definition at line 696 of file qproperty_p.h.

◆ value()

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
parameter_type QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::value ( ) const
inline

Definition at line 566 of file qproperty_p.h.

References qGetBindingStorage(), and storage.

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ QtPrivate::QBindableInterfaceForProperty

template<typename Class , typename T , auto Offset, auto Setter, auto Signal = nullptr, auto Getter = nullptr>
template<typename Property , typename >
friend class QtPrivate::QBindableInterfaceForProperty
friend

Definition at line 511 of file qproperty_p.h.


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