QUntypedBindable Class
QUntypedBindable è un'interfaccia uniforme che copre proprietà associabili come QProperty\<T\> e QObjectBindableProperty di qualsiasi tipo T. Altro...
| Intestazione: | #include <QUntypedBindable> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| A partire da: | Qt 6.0 |
| Ereditato da: |
Funzioni pubbliche
| 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() |
Descrizione dettagliata
QUntypedBindable è un'interfaccia generica con cancellazione completa dei tipi che serve a incapsulare le proprietà associabili. È possibile utilizzarla per interagire con le proprietà senza conoscerne il tipo né preoccuparsi di quale tipo di proprietà associabile si tratti (ad esempio QProperty o QObjectBindableProperty). Nella maggior parte dei casi, è preferibile utilizzare QBindable<T> (che è generica rispetto all'implementazione della proprietà ma ha un tipo fisso).
Documentazione delle funzioni membro
[constexpr noexcept default] QUntypedBindable::QUntypedBindable()
Crea implicitamente un oggetto QUntypedBindable. Si trova in uno stato non valido.
Vedi anche isValid().
template <typename Property> QUntypedBindable::QUntypedBindable(Property *property)
Crea un oggetto `QUntypedBindable` a partire dalla proprietà ` property`. Se `Property` è di tipo `const`, l’oggetto `QUntypedBindable` sarà di sola lettura. Se ` property ` è nullo, l’oggetto `QUntypedBindable` non sarà valido.
Vedi anche isValid() e isReadOnly().
template <typename Functor> QPropertyNotifier QUntypedBindable::addNotifier(Functor f)
Installa ` f ` come gestore delle modifiche. Ogni volta che la proprietà sottostante cambia, verrà chiamata la funzione ` f `, a condizione che l'oggetto ` QPropertyNotifier ` restituito e la proprietà rimangano attivi.
In alcuni casi questo metodo è più facile da usare rispetto a ` onValueChanged()`, poiché l'oggetto restituito non è un template. Può quindi essere memorizzato più facilmente, ad esempio come membro di una classe.
Vedi anche onValueChanged() e subscribe().
QUntypedPropertyBinding QUntypedBindable::binding() const
Restituisce il binding della proprietà sottostante, se presente, oppure, in caso contrario, un oggetto QUntypedPropertyBinding creato con i valori predefiniti.
Vedi anche setBinding() e hasBinding().
bool QUntypedBindable::hasBinding() const
Restituisce ` true ` se la proprietà sottostante ha un binding.
[since 6.1] bool QUntypedBindable::isReadOnly() const
Restituisce true se l'QUntypedBindable e è di sola lettura.
Questa funzione è stata introdotta in Qt 6.1.
bool QUntypedBindable::isValid() const
Restituisce "true" se l'QUntypedBindable è valido. I metodi chiamati su un QUntypedBindable non valido generalmente non hanno alcun effetto, salvo diversa indicazione.
QUntypedPropertyBinding QUntypedBindable::makeBinding(const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION) const
Crea un binding che restituisce il valore delle proprietà sottostanti, utilizzando una fonte specificata location.
[since 6.2] QMetaType QUntypedBindable::metaType() const
Restituisce il metatipo della proprietà da cui è stato creato l’ QUntypedBindable. Se il bindable non è valido, verrà restituito un metatipo non valido.
Questa funzione è stata introdotta in Qt 6.2.
Vedi anche ` isValid()` e ` QUntypedPropertyBinding::valueMetaType()`.
template <typename Functor> QPropertyChangeHandler<Functor> QUntypedBindable::onValueChanged(Functor f) const
Installa f come gestore di modifiche. Ogni volta che la proprietà sottostante cambia, verrà chiamato f, a condizione che l'QPropertyChangeHandler restituito e la proprietà rimangano attivi. Ad ogni modifica del valore, il gestore viene chiamato immediatamente oppure in modo differito, a seconda del contesto.
Vedi anche QProperty::onValueChanged() e subscribe().
bool QUntypedBindable::setBinding(const QUntypedPropertyBinding &binding)
Imposta il binding della proprietà sottostante su binding. Questa operazione non ha alcun effetto se QUntypedBindable è di sola lettura, nullo o se il tipo di binding non corrisponde al tipo della proprietà sottostante.
Restituisce ` true ` quando l'associazione è stata impostata correttamente.
Vedi anche binding() e QUntypedPropertyBinding::valueMetaType().
template <typename Functor> QPropertyChangeHandler<Functor> QUntypedBindable::subscribe(Functor f) const
Si comporta come una chiamata a f seguita da onValueChanged(f),
Vedi anche onValueChanged().
[since 6.1] QUntypedPropertyBinding QUntypedBindable::takeBinding()
Rimuove il binding attualmente impostato dalla proprietà e la restituisce. Se non è impostato alcun binding, restituisce un oggetto ` QUntypedPropertyBinding ` creato con il costruttore predefinito.
Questa funzione è stata introdotta in 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.