QUntypedBindable Class
QUntypedBindable es una interfaz uniforme para propiedades vinculables como QProperty\<T\> y QObjectBindableProperty de cualquier tipo T. Más...
| Encabezado: | #include <QUntypedBindable> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| Desde: | Qt 6.0 |
| Heredado por: |
Funciones públicas
| QUntypedBindable() | |
| QUntypedBindable(Property *property) | |
| QPropertyNotifier | addNotifier(Functor f) |
| QUntypedPropertyBinding | binding() const |
| bool | hasBinding() const |
(since 6.1) bool | isReadOnly() const |
| bool | isValid() const |
| QUntypedPropertyBinding | makeBinding(const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) const |
(since 6.2) QMetaType | metaType() const |
| QPropertyChangeHandler<Functor> | onValueChanged(Functor f) const |
| bool | setBinding(const QUntypedPropertyBinding &binding) |
| QPropertyChangeHandler<Functor> | subscribe(Functor f) const |
(since 6.1) QUntypedPropertyBinding | takeBinding() |
Descripción detallada
QUntypedBindable es una interfaz genérica con borrado total de tipos para envolver propiedades enlazables. Se puede utilizar para interactuar con propiedades sin conocer su tipo ni tener en cuenta de qué tipo de propiedad enlazable se trata (por ejemplo, QProperty o QObjectBindableProperty). En la mayoría de los casos, es preferible utilizar QBindable<T> (que es genérico respecto a la implementación de la propiedad, pero tiene un tipo fijo).
Documentación de las funciones miembro
[constexpr noexcept default] QUntypedBindable::QUntypedBindable()
Crea por defecto un objeto de tipo QUntypedBindable. Se encuentra en un estado no válido.
Véase también isValid().
template <typename Property> QUntypedBindable::QUntypedBindable(Property *property)
Crea un objeto `QUntypedBindable` a partir de la propiedad ` property`. Si `Property` es `const`, el objeto `QUntypedBindable` será de solo lectura. Si ` property ` es `null`, el objeto `QUntypedBindable` no será válido.
Véase también isValid() y isReadOnly().
template <typename Functor> QPropertyNotifier QUntypedBindable::addNotifier(Functor f)
Instala ` f ` como gestor de cambios. Cada vez que cambie la propiedad subyacente, se llamará a ` f `, siempre y cuando se mantengan activos tanto el objeto ` QPropertyNotifier ` devuelto como la propiedad.
En algunos casos, este método resulta más fácil de utilizar que onValueChanged(), ya que el objeto devuelto no es una plantilla. Por lo tanto, se puede almacenar más fácilmente, por ejemplo, como miembro de una clase.
Véanse también onValueChanged() y subscribe().
QUntypedPropertyBinding QUntypedBindable::binding() const
Devuelve el enlace de la propiedad subyacente, si lo hay, o, en caso contrario, un objeto de tipo ` QUntypedPropertyBinding ` creado de forma predeterminada.
Véanse también setBinding() y hasBinding().
bool QUntypedBindable::hasBinding() const
Devuelve « true » si la propiedad subyacente tiene una vinculación.
[since 6.1] bool QUntypedBindable::isReadOnly() const
Devuelve «true» si el ` QUntypedBindable ` es de solo lectura.
Esta función se introdujo en Qt 6.1.
bool QUntypedBindable::isValid() const
Devuelve «true» si el objeto « QUntypedBindable » es válido. Los métodos que se invocan sobre un objeto « QUntypedBindable » no válido no suelen tener ningún efecto, salvo que se indique lo contrario.
QUntypedPropertyBinding QUntypedBindable::makeBinding(const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
Crea un enlace que devuelve el valor de las propiedades subyacentes, utilizando una fuente especificada location.
[since 6.2] QMetaType QUntypedBindable::metaType() const
Devuelve el metatipo de la propiedad a partir de la cual se creó el « QUntypedBindable ». Si el «bindable» no es válido, se devolverá un metatipo no válido.
Esta función se introdujo en Qt 6.2.
Véase también isValid() y QUntypedPropertyBinding::valueMetaType().
template <typename Functor> QPropertyChangeHandler<Functor> QUntypedBindable::onValueChanged(Functor f) const
Instala ` f ` como controlador de cambios. Cada vez que cambie la propiedad subyacente, se llamará a ` f `, siempre y cuando se mantengan activos tanto ` QPropertyChangeHandler ` como la propiedad. Ante cada cambio de valor, el controlador se invoca de forma inmediata o se aplaza, dependiendo del contexto.
Véase también QProperty::onValueChanged() y subscribe().
bool QUntypedBindable::setBinding(const QUntypedPropertyBinding &binding)
Establece el enlace de la propiedad subyacente a binding. Esto no tiene ningún efecto si QUntypedBindable es de solo lectura, es nulo o si el tipo de binding no coincide con el tipo de la propiedad subyacente.
Devuelve ` true ` cuando el enlace se ha establecido correctamente.
Véase también binding() y QUntypedPropertyBinding::valueMetaType().
template <typename Functor> QPropertyChangeHandler<Functor> QUntypedBindable::subscribe(Functor f) const
Se comporta como una llamada a f seguida de onValueChanged(f),
Véase también onValueChanged().
[since 6.1] QUntypedPropertyBinding QUntypedBindable::takeBinding()
Elimina el enlace establecido actualmente de la propiedad y la devuelve. Devuelve un objeto ` QUntypedPropertyBinding ` construido de forma predeterminada si no hay ningún enlace establecido.
Esta función se introdujo en Qt 6.1.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.