![]() |
Qt 6.x
The Qt SDK
|
\macro Q_OBJECT_BINDABLE_PROPERTY(containingClass, type, name, signal) More...
#include <qproperty_p.h>
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 |
![]() | |
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 = std::conditional_t< std::is_pointer_v< T >, const T &, std::conditional_t< QTypeTraits::is_dereferenceable_v< T >, const T &, void > > |
Friends | |
template<typename Property , typename > | |
class | QtPrivate::QBindableInterfaceForProperty |
Additional Inherited Members | |
![]() | |
T | val = T() |
![]() | |
static constexpr bool | UseReferences = !(std::is_arithmetic_v<T> || std::is_enum_v<T> || std::is_pointer_v<T>) |
\macro Q_OBJECT_BINDABLE_PROPERTY(containingClass, type, name, signal)
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.
\macro Q_OBJECT_BINDABLE_PROPERTY_WITH_ARGS(containingClass, type, name, initialvalue, signal)
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.
\inmodule QtCore
The QObjectCompatProperty class is a template class to help port old properties to the bindable property system.
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.
Definition at line 471 of file qproperty_p.h.
using QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::arrow_operator_result = typename QPropertyData<T>::arrow_operator_result |
Definition at line 520 of file qproperty_p.h.
using QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::parameter_type = typename QPropertyData<T>::parameter_type |
Definition at line 519 of file qproperty_p.h.
using QObjectCompatProperty< Class, T, Offset, Setter, Signal, Getter >::value_type = typename QPropertyData<T>::value_type |
Definition at line 518 of file qproperty_p.h.
|
default |
|
inlineexplicit |
Definition at line 523 of file qproperty_p.h.
|
inlineexplicit |
Definition at line 524 of file qproperty_p.h.
|
inline |
Definition at line 677 of file qproperty_p.h.
|
inline |
Definition at line 650 of file qproperty_p.h.
References QBindingStorage::bindingData(), and qGetBindingStorage().
|
inline |
Definition at line 683 of file qproperty_p.h.
References qGetBindingStorage(), and storage.
|
inline |
Definition at line 603 of file qproperty_p.h.
References QtPrivate::QPropertyBindingData::binding(), QBindingStorage::bindingData(), and qGetBindingStorage().
|
inline |
Definition at line 618 of file qproperty_p.h.
References d, qGetBindingStorage(), and storage.
|
inline |
Definition at line 662 of file qproperty_p.h.
|
inline |
Definition at line 552 of file qproperty_p.h.
|
inline |
Definition at line 547 of file qproperty_p.h.
|
inline |
Definition at line 535 of file qproperty_p.h.
|
inline |
Definition at line 568 of file qproperty_p.h.
References setValue().
|
inline |
Definition at line 608 of file qproperty_p.h.
References qGetBindingStorage(), and storage.
|
inline |
Definition at line 574 of file qproperty_p.h.
References QBindingStorage::bindingData(), qGetBindingStorage(), and QtPrivate::QPropertyBindingData::setBinding().
|
inline |
Definition at line 582 of file qproperty_p.h.
References QUntypedPropertyBinding::isNull(), and QUntypedPropertyBinding::valueMetaType().
|
inline |
Definition at line 592 of file qproperty_p.h.
References Qt::makePropertyBinding().
|
inline |
Definition at line 557 of file qproperty_p.h.
References qGetBindingStorage(), and storage.
|
inline |
Definition at line 669 of file qproperty_p.h.
|
inline |
Definition at line 656 of file qproperty_p.h.
|
inline |
Definition at line 526 of file qproperty_p.h.
References qGetBindingStorage(), and storage.
|
friend |
Definition at line 474 of file qproperty_p.h.