QUntypedBindable 是统一接口涵盖可绑定特性,像
QProperty\<T\>
and
QObjectBindableProperty
的任何类型
T
.
更多...
头: | #include <QUntypedBindable> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
Since: | Qt 6.0 |
继承者: | QBindable |
QUntypedBindable () | |
QUntypedBindable (Property * property ) | |
QPropertyNotifier | addNotifier (Functor f ) |
QUntypedPropertyBinding | binding () const |
bool | hasBinding () const |
bool | isReadOnly () const |
bool | isValid () const |
QUntypedPropertyBinding | makeBinding (const QPropertyBindingSourceLocation & location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) const |
QMetaType | metaType () const |
QPropertyChangeHandler<Functor> | onValueChanged (Functor f ) const |
bool | setBinding (const QUntypedPropertyBinding & binding ) |
QPropertyChangeHandler<Functor> | subscribe (Functor f ) const |
QUntypedPropertyBinding | takeBinding () |
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.
[constexpr]
QUntypedBindable::
QUntypedBindable
()
Default-constructs a QUntypedBindable. It is in an invalid state.
另请参阅 isValid ().
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.
另请参阅 isValid () 和 isReadOnly ().
Installs
f
as a change handler. Whenever the underlying property changes,
f
will be called, as long as the returned
QPropertyNotifier
and the property are kept alive.
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.
另请参阅 onValueChanged () 和 subscribe ().
Returns the underlying property's binding if there is any, or a default constructed QUntypedPropertyBinding otherwise.
另请参阅 setBinding () 和 hasBinding ().
返回
true
if the underlying property has a binding.
[since 6.1]
bool
QUntypedBindable::
isReadOnly
() const
返回 true 若 QUntypedBindable is read-only.
该函数在 Qt 6.1 引入。
返回 true 若 QUntypedBindable is valid. Methods called on an invalid QUntypedBindable generally have no effect, unless otherwise noted.
Creates a binding returning the underlying properties' value, using a specified source location .
[since 6.2]
QMetaType
QUntypedBindable::
metaType
() const
Returns the metatype of the property from which the QUntypedBindable was created. If the bindable is invalid, an invalid metatype will be returned.
该函数在 Qt 6.2 引入。
另请参阅 isValid ().
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. On each value change, the handler is either called immediately, or deferred, depending on the context.
另请参阅 onValueChanged() and subscribe ().
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.
返回
true
when the binding was successfully set.
另请参阅 binding ().
Behaves like a call to
f
followed by
onValueChanged(f)
,
另请参阅 onValueChanged ().
[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.
该函数在 Qt 6.1 引入。