QUntypedBindable Class

QUntypedBindable is a uniform interface over bindable properties like QProperty\<T\> and QObjectBindableProperty of any type T. More...

Header: #include <QUntypedBindable>
CMake: find_package(Qt6 COMPONENTS Core REQUIRED) target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 6.0
Inherited By:

QBindable

Public Functions

QUntypedBindable(Property *property)
QUntypedBindable()
QPropertyChangeHandler<Functor> onValueChanged(Functor f)
bool setBinding(const QUntypedPropertyBinding &binding)
QUntypedPropertyBinding takeBinding()

Detailed Description

QUntypedBindable is a fully type-erased generic interface to wrap bindable properties. You can use it to interact with properties without knowing their type nor caring what kind of bindable property they are (e.g. QProperty or QObjectBindableProperty). For most use cases, using QBindable<T> (which is generic over the property implementation but has a fixed type) should be preferred.

Member Function Documentation

template <typename Property> QUntypedBindable::QUntypedBindable(Property *property)

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() and isReadOnly().

QUntypedBindable::QUntypedBindable()

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

See also isValid().

template <typename Functor> QPropertyChangeHandler<Functor> QUntypedBindable::onValueChanged(Functor f)

Installs f as a change handler. Whenever the underlying property changes, f will be called, as long as the returned QPropertyChangeHandler and the property are kept alive.

See also template<typename, T>, QProperty::onValueChanged(), and subscribe().

bool QUntypedBindable::setBinding(const QUntypedPropertyBinding &binding)

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().

[since 6.1] QUntypedPropertyBinding QUntypedBindable::takeBinding()

Removes the currently set binding from the property and returns it. Returns a default-constructed QUntypedPropertyBinding if no binding is set.

This function was introduced in Qt 6.1.

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.1/quntypedbindable.html