QMetaAssociation Class
La classe QMetaAssociation consente l'accesso con cancellazione del tipo ai contenitori associativi. Per saperne di più...
| Intestazione: | #include <QMetaAssociation> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| A partire da: | Qt 6.0 |
| Eredita da: | QMetaContainer |
Confronto tra QMetaAssociation
| Categoria | Tipi comparabili |
|---|---|
| uguaglianza | QMetaAssociation |
Tipi pubblici
(since 6.11) class | Iterable |
Funzioni pubbliche
| QMetaAssociation() | |
| bool | canContainsKey() const |
| bool | canCreateConstIteratorAtKey() const |
| bool | canCreateIteratorAtKey() const |
| bool | canGetKeyAtConstIterator() const |
| bool | canGetKeyAtIterator() const |
| bool | canGetMappedAtConstIterator() const |
| bool | canGetMappedAtIterator() const |
| bool | canGetMappedAtKey() const |
| bool | canInsertKey() const |
| bool | canRemoveKey() const |
| bool | canSetMappedAtIterator() const |
| bool | canSetMappedAtKey() const |
| bool | containsKey(const void *container, const void *key) const |
| void * | createConstIteratorAtKey(const void *container, const void *key) const |
| void * | createIteratorAtKey(void *container, const void *key) const |
| void | insertKey(void *container, const void *key) const |
| void | keyAtConstIterator(const void *iterator, void *key) const |
| void | keyAtIterator(const void *iterator, void *key) const |
| QMetaType | keyMetaType() const |
| void | mappedAtConstIterator(const void *iterator, void *mapped) const |
| void | mappedAtIterator(const void *iterator, void *mapped) const |
| void | mappedAtKey(const void *container, const void *key, void *mapped) const |
| QMetaType | mappedMetaType() const |
| void | removeKey(void *container, const void *key) const |
| void | setMappedAtIterator(const void *iterator, const void *mapped) const |
| void | setMappedAtKey(void *container, const void *key, const void *mapped) const |
Membri pubblici statici
(since 6.0) QMetaAssociation | fromContainer() |
Elementi non membri correlati
| bool | operator!=(const QMetaAssociation &lhs, const QMetaAssociation &rhs) |
| bool | operator==(const QMetaAssociation &lhs, const QMetaAssociation &rhs) |
Descrizione dettagliata
La classe fornisce una serie di operazioni su contenitori primitivi, utilizzando void* come operandi. In questo modo, è possibile manipolare un contenitore generico recuperato da un Variant senza conoscerne il tipo.
QMetaAssociation copre sia i contenitori con valori mappati, come QMap o QHash, sia i contenitori che contengono solo chiavi, come QSet.
Gli argomenti di tipo `void*` dei vari metodi vengono in genere creati utilizzando un ` QVariant ` del rispettivo contenitore o tipo di valore e chiamando i suoi metodi ` QVariant::data()` o ` QVariant::constData()`. Tuttavia, è anche possibile passare semplici puntatori a oggetti del tipo contenitore o valore.
L’invalidazione degli iteratori segue le regole stabilite dai contenitori sottostanti e non è espressa nell’API. Pertanto, per un contenitore veramente generico, qualsiasi iteratore dovrebbe essere considerato non valido dopo ogni operazione di scrittura.
Vedi anche QMetaContainer, QMetaSequence, QIterable e QIterator.
Documentazione delle funzioni membro
[constexpr noexcept default] QMetaAssociation::QMetaAssociation()
Crea un'istanza di ` QMetaAssociation` con i valori predefiniti.
bool QMetaAssociation::canContainsKey() const
Restituisce ` true ` se è possibile interrogare il contenitore in base alle chiavi utilizzando ` containsKey()`, altrimenti restituisce ` false`.
bool QMetaAssociation::canCreateConstIteratorAtKey() const
Restituisce ` true ` se è possibile creare un iteratore `const` che punta a una voce nel contenitore utilizzando ` createConstIteratorAtKey()`, altrimenti restituisce `false`.
bool QMetaAssociation::canCreateIteratorAtKey() const
Restituisce ` true ` se è possibile creare un iteratore che punta a una voce nel contenitore utilizzando ` createIteratorAtKey()`; in caso contrario, restituisce `false`.
Vedi anche createIteratorAtKey().
bool QMetaAssociation::canGetKeyAtConstIterator() const
Restituisce ` true ` se è possibile recuperare una chiave da un iteratore `const` utilizzando ` keyAtConstIterator()`, altrimenti restituisce ` false`.
Vedi anche keyAtConstIterator().
bool QMetaAssociation::canGetKeyAtIterator() const
Restituisce ` true ` se è possibile recuperare una chiave da un iteratore non costante utilizzando ` keyAtIterator()`, altrimenti restituisce ` false`.
Vedi anche keyAtIterator().
bool QMetaAssociation::canGetMappedAtConstIterator() const
Restituisce ` true ` se è possibile recuperare un valore mappato da un iteratore `const` utilizzando ` mappedAtConstIterator()`, altrimenti restituisce ` false`.
Vedi anche mappedAtConstIterator().
bool QMetaAssociation::canGetMappedAtIterator() const
Restituisce ` true ` se è possibile recuperare un valore mappato da un iteratore non costante utilizzando ` mappedAtIterator()`, altrimenti restituisce ` false`.
Vedi anche ` mappedAtIterator()`.
bool QMetaAssociation::canGetMappedAtKey() const
Restituisce ` true ` se è possibile interrogare il contenitore per ottenere i valori tramite ` mappedAtKey()`; in caso contrario, restituisce ` false`.
bool QMetaAssociation::canInsertKey() const
Restituisce ` true ` se è possibile aggiungere chiavi al contenitore utilizzando ` insertKey()`, altrimenti restituisce ` false`.
Vedi anche insertKey().
bool QMetaAssociation::canRemoveKey() const
Restituisce ` true ` se è possibile rimuovere le chiavi dal contenitore utilizzando ` removeKey()`, altrimenti restituisce ` false`.
Vedi anche removeKey().
bool QMetaAssociation::canSetMappedAtIterator() const
Restituisce ` true ` se è possibile impostare un valore mappato tramite un iteratore non costante utilizzando ` setMappedAtIterator()`, altrimenti restituisce ` false`.
Vedi anche setMappedAtIterator().
bool QMetaAssociation::canSetMappedAtKey() const
Restituisce ` true ` se i valori mappati possono essere modificati nel contenitore tramite ` setMappedAtKey()`; in caso contrario, restituisce ` false`.
Vedi anche setMappedAtKey().
bool QMetaAssociation::containsKey(const void *container, const void *key) const
Restituisce true se è possibile interrogare l'container per le chiavi e se contiene l'key, altrimenti restituisce false.
Vedi anche canContainsKey().
void *QMetaAssociation::createConstIteratorAtKey(const void *container, const void *key) const
Restituisce un iteratore const che punta alla voce di ` key ` nella struttura ` container`, se possibile. Se la voce non esiste, crea un iteratore const che punta alla fine della struttura ` container`. Se non è possibile creare alcun iteratore const, restituisce ` nullptr`.
L’iteratore const deve essere distrutto utilizzando destroyConstIterator().
Vedi anche canCreateConstIteratorAtKey(), constBegin(), constEnd() e destroyConstIterator().
void *QMetaAssociation::createIteratorAtKey(void *container, const void *key) const
Restituisce un iteratore non costante che punta alla voce di key nella struttura container, se possibile. Se la voce non esiste, crea un iteratore non costante che punta alla fine della struttura container. Se non è possibile creare alcun iteratore non costante, restituisce nullptr.
L’iteratore non costante deve essere distrutto utilizzando ` destroyIterator()`.
Vedi anche canCreateIteratorAtKey(), begin(), end() e destroyIterator().
[static constexpr, since 6.0] template <typename T> QMetaAssociation QMetaAssociation::fromContainer()
Restituisce l'QMetaAssociation e corrispondente al tipo specificato come parametro del modello.
Questa funzione è stata introdotta in Qt 6.0.
void QMetaAssociation::insertKey(void *container, const void *key) const
Inserisce l’ key nell’ container, se possibile. Se il contenitore contiene valori mappati, all’ key viene associato un valore mappato predefinito.
Vedi anche canInsertKey().
void QMetaAssociation::keyAtConstIterator(const void *iterator, void *key) const
Recupera la chiave indicata dalla costante iterator e la memorizza nella posizione di memoria indicata da key, se possibile.
Vedi anche canGetKeyAtConstIterator(), constBegin(), constEnd() e createConstIteratorAtKey().
void QMetaAssociation::keyAtIterator(const void *iterator, void *key) const
Recupera la chiave indicata dalla variabile non costante ` iterator ` e la memorizza nella posizione di memoria indicata da ` key`, se possibile.
Vedi anche canGetKeyAtIterator(), begin(), end() e createIteratorAtKey().
QMetaType QMetaAssociation::keyMetaType() const
Restituisce il tipo meta delle chiavi presenti nel contenitore.
void QMetaAssociation::mappedAtConstIterator(const void *iterator, void *mapped) const
Recupera il valore mappato indicato dalla costante iterator e lo memorizza nella posizione di memoria indicata da mapped, se possibile.
Vedi anche canGetMappedAtConstIterator(), constBegin(), constEnd() e createConstIteratorAtKey().
void QMetaAssociation::mappedAtIterator(const void *iterator, void *mapped) const
Recupera il valore mappato a cui punta il parametro non costante ` iterator ` e lo memorizza nella posizione di memoria indicata da ` mapped`, se possibile.
Vedi anche setMappedAtIterator(), canGetMappedAtIterator(), begin(), end() e createIteratorAtKey().
void QMetaAssociation::mappedAtKey(const void *container, const void *key, void *mapped) const
Recupera il valore mappato associato all'key nell'container e lo inserisce nella posizione di memoria indicata da mapped, se possibile.
Vedi anche setMappedAtKey() e canGetMappedAtKey().
QMetaType QMetaAssociation::mappedMetaType() const
Restituisce il tipo meta dei valori mappati nel contenitore.
void QMetaAssociation::removeKey(void *container, const void *key) const
Rimuove l'key e il valore associato mappato dall'container, se possibile.
Vedi anche canRemoveKey().
void QMetaAssociation::setMappedAtIterator(const void *iterator, const void *mapped) const
Scrive il valore di ` mapped ` nella posizione del contenitore indicata dalla variabile non costante ` iterator`, se possibile.
Vedi anche mappedAtIterator(), canSetMappedAtIterator(), begin(), end() e createIteratorAtKey().
void QMetaAssociation::setMappedAtKey(void *container, const void *key, const void *mapped) const
Sovrascrive il valore associato a ` key ` in ` container ` utilizzando il valore di ` mapped ` passato come argomento, se possibile.
Vedi anche mappedAtKey() e canSetMappedAtKey().
Elementi non membri correlati
[noexcept] bool operator!=(const QMetaAssociation &lhs, const QMetaAssociation &rhs)
Restituisce ` true ` se ` QMetaAssociation ` ( lhs ) rappresenta un tipo di contenitore diverso da ` QMetaAssociation ` ( rhs); in caso contrario, restituisce ` false`.
[noexcept] bool operator==(const QMetaAssociation &lhs, const QMetaAssociation &rhs)
Restituisce ` true ` se ` QMetaAssociation ` ( lhs ) rappresenta lo stesso tipo di contenitore di ` QMetaAssociation ` ( rhs); in caso contrario, restituisce ` false`.
© 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.