The QProperty class is a template class that enables automatic property bindings. More...
Header: | #include <QProperty> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
Since: | Qt 6.0 |
Inherits: | QPropertyData |
QProperty(T &&initialValue) | |
QProperty(const T &initialValue) | |
QProperty(Functor &&f) | |
QProperty(const QPropertyBinding<T> &binding) | |
QProperty() | |
QProperty<T> & | operator=(const QPropertyBinding<T> &newBinding) |
~QProperty() | |
QPropertyNotifier | addNotifier(Functor f) |
QPropertyBinding<T> | binding() const |
QPropertyChangeHandler<Functor> | onValueChanged(Functor f) |
QPropertyBinding<T> | setBinding(const QPropertyBinding<T> &newBinding) |
bool | setBinding(const QUntypedPropertyBinding &newBinding) |
QPropertyBinding<T> | setBinding(Functor f) |
void | setValue(QProperty::rvalue_ref newValue) |
void | setValue(QProperty::parameter_type newValue) |
QPropertyChangeHandler<Functor> | subscribe(Functor f) |
QPropertyBinding<T> | takeBinding() |
QProperty::parameter_type | value() const |
QProperty<T> & | operator=(QProperty::rvalue_ref newValue) |
QProperty<T> & | operator=(QProperty::parameter_type newValue) |
void | beginPropertyUpdateGroup() |
void | endPropertyUpdateGroup() |
QProperty<T> is one of the classes implementing Qt Bindable Properties. It is a container that holds an instance of T. You can assign a value to it and you can read it via the value() function or the T conversion operator. You can also tie the property to an expression that computes the value dynamically, the binding expression. It is represented as a C++ lambda and can be used to express relationships between different properties in your application.
Assigns newValue to this property and returns a reference to this QProperty.
Assigns newValue to this property and removes the property's associated binding, if present.
[default]
QProperty::QProperty(T &&initialValue)Move-Constructs a property with the provided initialValue.
[default]
QProperty::QProperty(const T &initialValue)Constructs a property with the provided initialValue.
Constructs a property that is tied to the provided binding expression f. The first time the property value is read, 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.
Constructs a property that is tied to the provided binding expression. The first time the property value is read, 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.
Constructs a property with a default constructed instance of T.
[default]
QProperty<T> &QProperty::operator=(const QPropertyBinding<T> &newBinding)Associates the value of this property with the provided newBinding expression and returns a reference to this property. The first time the property value is read, 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.
Destroys the property.
Subscribes the given functor f as a callback that is called whenever the value of the 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() and subscribe().
Returns the binding expression that is associated with this property. A default constructed QPropertyBinding<T> will be returned if no such association exists.
See also setBinding().
Registers the given functor f as a callback that shall be called whenever the value of the 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.
Associates the value of this property with the provided newBinding expression and returns the previously associated binding. The first time the property value is read, 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.
See also binding().
This is an overloaded function.
Associates the value of this property with the provided newBinding expression. The first time the property value is read, 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.
This is an overloaded function.
Associates the value of this property with the provided functor f and returns the previously associated binding. The first time the property value is read, the binding is evaluated by invoking the call operator () of f. Whenever a dependency of the binding changes, the binding will be re-evaluated the next time the value of this property is read.
See also Formulating a Property Binding.
Subscribes the given functor f as a callback that is called immediately and whenever the value of the 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 can be copied and 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.
Disassociates the binding expression from this 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.
Returns the value of the property. This may evaluate a binding expression that is tied to this property, before returning the value.
See also setValue().
[since 6.2]
void beginPropertyUpdateGroup()Marks the beginning of a property update group. Inside this group, changing a property does neither immediately update any dependent properties nor does it trigger change notifications. Those are instead deferred until the group is ended by a call to endPropertyUpdateGroup.
Groups can be nested. In that case, the deferral ends only after the outermost group has been ended.
Note: Change notifications are only send after all property values affected by the group have been updated to their new values. This allows re-establishing a class invariant if multiple properties need to be updated, preventing any external observer from noticing an inconsistent state.
This function was introduced in Qt 6.2.
See also Qt::endPropertyUpdateGroup.
[since 6.2]
void endPropertyUpdateGroup()Ends a property update group. If the outermost group has been ended, and deferred binding evaluations and notifications happen now.
Warning: Calling endPropertyUpdateGroup without a preceding call to beginPropertyUpdateGroup results in undefined behavior.
This function was introduced in Qt 6.2.
See also Qt::beginPropertyUpdateGroup.