Auf dieser Seite

QMetaAssociation Class

Die Klasse „QMetaAssociation“ ermöglicht den typunabhängigen Zugriff auf assoziative Container. Mehr...

Header: #include <QMetaAssociation>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Seit: Qt 6.0
Erbt von: QMetaContainer

Vergleiche zu QMetaAssociation

KategorieVergleichbare Typen
GleichheitQMetaAssociation

Öffentliche Typen

(since 6.11) class Iterable

Öffentliche Funktionen

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

Statische öffentliche Mitglieder

(since 6.0) QMetaAssociation fromContainer()
bool operator!=(const QMetaAssociation &lhs, const QMetaAssociation &rhs)
bool operator==(const QMetaAssociation &lhs, const QMetaAssociation &rhs)

Detaillierte Beschreibung

Die Klasse stellt eine Reihe von Operationen für primitive Container bereit, die `void*` als Operanden verwenden. Auf diese Weise können Sie einen generischen Container bearbeiten, der aus einem `Variant` abgerufen wurde, ohne dessen Typ zu kennen.

QMetaAssociation deckt sowohl Container mit zugeordneten Werten wie ` QMap ` oder ` QHash` als auch Container ab, die nur Schlüssel enthalten, wie beispielsweise ` QSet`.

Die `void*`-Argumente für die verschiedenen Methoden werden in der Regel erstellt, indem ein ` QVariant ` des jeweiligen Container- oder Werttyps verwendet und dessen Methoden ` QVariant::data()` oder ` QVariant::constData()` aufgerufen werden. Sie können jedoch auch einfache Zeiger auf Objekte des Container- oder Werttyps übergeben.

Die Ungültigmachung von Iteratoren folgt den von den zugrunde liegenden Containern vorgegebenen Regeln und wird in der API nicht explizit behandelt. Daher sollten bei einem wirklich generischen Container alle Iteratoren nach jedem Schreibvorgang als ungültig betrachtet werden.

Siehe auch QMetaContainer, QMetaSequence, QIterable und QIterator.

Dokumentation zu Mitgliedsfunktionen

[constexpr noexcept default] QMetaAssociation::QMetaAssociation()

Erstellt standardmäßig eine Instanz von „ QMetaAssociation “.

bool QMetaAssociation::canContainsKey() const

Gibt ` true ` zurück, wenn der Container mithilfe von ` containsKey()` nach Schlüsseln abgefragt werden kann; andernfalls wird ` false` zurückgegeben.

bool QMetaAssociation::canCreateConstIteratorAtKey() const

Gibt „ true “ zurück, wenn mit „ createConstIteratorAtKey()“ ein const-Iterator erstellt werden kann, der auf einen Eintrag im Container verweist; andernfalls wird „false“ zurückgegeben.

bool QMetaAssociation::canCreateIteratorAtKey() const

Gibt „ true “ zurück, wenn mithilfe von „ createIteratorAtKey()“ ein Iterator erstellt werden kann, der auf einen Eintrag im Container verweist; andernfalls wird „false“ zurückgegeben.

Siehe auch ` createIteratorAtKey()`.

bool QMetaAssociation::canGetKeyAtConstIterator() const

Gibt „ true “ zurück, wenn ein Schlüssel mithilfe von „ keyAtConstIterator()“ aus einem const-Iterator abgerufen werden kann; andernfalls wird „ false “ zurückgegeben.

Siehe auch ` keyAtConstIterator()`.

bool QMetaAssociation::canGetKeyAtIterator() const

Gibt „ true “ zurück, wenn ein Schlüssel mithilfe von „ keyAtIterator()“ aus einem nicht-konstanten Iterator abgerufen werden kann; andernfalls wird „ false “ zurückgegeben.

Siehe auch ` keyAtIterator()`.

bool QMetaAssociation::canGetMappedAtConstIterator() const

Gibt „ true “ zurück, wenn ein zugeordneter Wert mithilfe von „ mappedAtConstIterator()“ aus einem konstanten Iterator abgerufen werden kann; andernfalls wird „ false “ zurückgegeben.

Siehe auch ` mappedAtConstIterator()`.

bool QMetaAssociation::canGetMappedAtIterator() const

Gibt „ true “ zurück, wenn ein zugeordneter Wert mithilfe von „ mappedAtIterator()“ aus einem nicht-konstanten Iterator abgerufen werden kann; andernfalls wird „ false “ zurückgegeben.

Siehe auch ` mappedAtIterator()`.

bool QMetaAssociation::canGetMappedAtKey() const

Gibt „ true “ zurück, wenn der Container mithilfe von ` mappedAtKey()` nach Werten abgefragt werden kann; andernfalls wird „ false “ zurückgegeben.

bool QMetaAssociation::canInsertKey() const

Gibt „ true “ zurück, wenn Schlüssel mithilfe von „ insertKey()“ zum Container hinzugefügt werden können; andernfalls wird „ false “ zurückgegeben.

Siehe auch ` insertKey()`.

bool QMetaAssociation::canRemoveKey() const

Gibt „ true “ zurück, wenn Schlüssel mithilfe von „ removeKey()“ aus dem Container entfernt werden können; andernfalls wird „ false “ zurückgegeben.

Siehe auch ` removeKey()`.

bool QMetaAssociation::canSetMappedAtIterator() const

Gibt „ true “ zurück, wenn ein zugeordneter Wert über einen nicht-konstanten Iterator mithilfe von ` setMappedAtIterator()` gesetzt werden kann; andernfalls wird „ false “ zurückgegeben.

Siehe auch ` setMappedAtIterator()`.

bool QMetaAssociation::canSetMappedAtKey() const

Gibt „ true “ zurück, wenn zugeordnete Werte im Container mithilfe von „ setMappedAtKey()“ geändert werden können; andernfalls wird „ false “ zurückgegeben.

Siehe auch ` setMappedAtKey()`.

bool QMetaAssociation::containsKey(const void *container, const void *key) const

Gibt „ true “ zurück, wenn der „ container “ nach Schlüsseln abgefragt werden kann und die „ key “ enthält; andernfalls wird „ false “ zurückgegeben.

Siehe auch canContainsKey().

void *QMetaAssociation::createConstIteratorAtKey(const void *container, const void *key) const

Gibt einen const-Iterator zurück, der auf den Eintrag von ` key ` in ` container` verweist, sofern dies möglich ist. Falls der Eintrag nicht existiert, wird ein const-Iterator erstellt, der auf das Ende von ` container` verweist. Kann kein const-Iterator erstellt werden, wird ` nullptr` zurückgegeben.

Der const-Iterator muss mit ` destroyConstIterator()` zerstört werden.

Siehe auch canCreateConstIteratorAtKey(), constBegin(), constEnd() und destroyConstIterator().

void *QMetaAssociation::createIteratorAtKey(void *container, const void *key) const

Gibt einen nicht-konstanten Iterator zurück, der auf den Eintrag von ` key ` in ` container` zeigt, sofern dies möglich ist. Falls der Eintrag nicht existiert, wird ein nicht-konstanter Iterator erstellt, der auf das Ende von ` container` zeigt. Kann kein nicht-konstanter Iterator erstellt werden, wird ` nullptr` zurückgegeben.

Der nicht-konstante Iterator muss mit ` destroyIterator()` zerstört werden.

Siehe auch „ canCreateIteratorAtKey()“, „ begin()“, „ end()“ und „ destroyIterator()“.

[static constexpr, since 6.0] template <typename T> QMetaAssociation QMetaAssociation::fromContainer()

Gibt die „ QMetaAssociation “ zurück, die dem als Vorlagenparameter angegebenen Typ entspricht.

Diese Funktion wurde in Qt 6.0 eingeführt.

void QMetaAssociation::insertKey(void *container, const void *key) const

Fügt die „ key “ nach Möglichkeit in den „ container “ ein. Wenn der Container zugeordnete Werte enthält, wird der „ key “ ein zugeordneter Standardwert zugewiesen.

Siehe auch canInsertKey().

void QMetaAssociation::keyAtConstIterator(const void *iterator, void *key) const

Ruft den Schlüssel ab, auf den die Konstante ` iterator ` verweist, und speichert ihn, sofern möglich, an der Speicheradresse, auf die ` key` verweist.

Siehe auch canGetKeyAtConstIterator(), constBegin(), constEnd() und createConstIteratorAtKey().

void QMetaAssociation::keyAtIterator(const void *iterator, void *key) const

Ruft den Schlüssel ab, auf den der nicht-konstante Zeiger ` iterator ` verweist, und speichert ihn, sofern möglich, an der Speicheradresse, auf die ` key` verweist.

Siehe auch canGetKeyAtIterator(), begin(), end() und createIteratorAtKey().

QMetaType QMetaAssociation::keyMetaType() const

Gibt den Metatyp für die Schlüssel im Container zurück.

void QMetaAssociation::mappedAtConstIterator(const void *iterator, void *mapped) const

Ruft den zugeordneten Wert ab, auf den der Konstante „ iterator “ verweist, und speichert ihn, sofern möglich, an der Speicheradresse, auf die „ mapped “ verweist.

Siehe auch canGetMappedAtConstIterator(), constBegin(), constEnd() und createConstIteratorAtKey().

void QMetaAssociation::mappedAtIterator(const void *iterator, void *mapped) const

Ruft den zugeordneten Wert ab, auf den das nicht-konstante ` iterator ` verweist, und speichert ihn, sofern möglich, an der Speicheradresse, auf die ` mapped` verweist.

Siehe auch setMappedAtIterator(), canGetMappedAtIterator(), begin(), end() und createIteratorAtKey().

void QMetaAssociation::mappedAtKey(const void *container, const void *key, void *mapped) const

Ruft den zugeordneten Wert ab, der mit dem ` key ` im ` container ` verknüpft ist, und speichert ihn an der Speicheradresse, auf die ` mapped` verweist, sofern dies möglich ist.

Siehe auch setMappedAtKey() und canGetMappedAtKey().

QMetaType QMetaAssociation::mappedMetaType() const

Gibt den Metatyp für die zugeordneten Werte im Container zurück.

void QMetaAssociation::removeKey(void *container, const void *key) const

Entfernt, sofern möglich, das „ key “ und den zugehörigen zugeordneten Wert aus dem „ container “.

Siehe auch „ canRemoveKey()“.

void QMetaAssociation::setMappedAtIterator(const void *iterator, const void *mapped) const

Schreibt den Wert von „ mapped “ in den Container, auf den das nicht-konstante „ iterator “ verweist, sofern dies möglich ist.

Siehe auch „ mappedAtIterator()“, „ canSetMappedAtIterator()“, „ begin()“, „ end()“ und „ createIteratorAtKey()“.

void QMetaAssociation::setMappedAtKey(void *container, const void *key, const void *mapped) const

Überschreibt den Wert, der mit dem Parameter „ key “ im Parameter „ container “ verknüpft ist, durch den als Argument übergebenen Wert „ mapped “, sofern dies möglich ist.

Siehe auch mappedAtKey() und canSetMappedAtKey().

Verwandte Nicht-Mitglieder

[noexcept] bool operator!=(const QMetaAssociation &lhs, const QMetaAssociation &rhs)

Gibt „ true “ zurück, wenn „ QMetaAssociation “ ( lhs ) einen anderen Containertyp darstellt als „ QMetaAssociation “ ( rhs); andernfalls wird „ false “ zurückgegeben.

[noexcept] bool operator==(const QMetaAssociation &lhs, const QMetaAssociation &rhs)

Gibt „ true “ zurück, wenn „ QMetaAssociation “ lhs denselben Containertyp darstellt wie „ QMetaAssociation “ rhs; andernfalls wird „ false “ zurückgegeben.

© 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.