QAssociativeIterable Class
QAssociativeIterable 클래스는 QVariant.. . 더 보기....
헤더: | #include <QAssociativeIterable> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
상속합니다: | QIterable |
공개 유형
공용 함수
bool | containsKey(const QVariant &key) |
QAssociativeIterable::const_iterator | find(const QVariant &key) const |
void | insertKey(const QVariant &key) |
QAssociativeIterable::iterator | mutableFind(const QVariant &key) |
void | removeKey(const QVariant &key) |
void | setValue(const QVariant &key, const QVariant &mapped) |
QVariant | value(const QVariant &key) const |
상세 설명
이 클래스는 QVariant 에 보관된 연관 컨테이너의 요소에 액세스하는 여러 메서드를 허용합니다. QVariant 에서 QVariantHash 또는 QVariantMap 로 변환할 수 있거나 사용자 정의 변경 가능한 보기가 등록된 경우 QAssociativeIterable의 인스턴스를 추출할 수 있습니다.
QHash<int, QString> mapping; mapping.insert(7, "Seven"); mapping.insert(11, "Eleven"); mapping.insert(42, "Forty-two");QVariant variant = QVariant::fromValue(mapping);if (variant.canConvert<QVariantHash>()) { QAssociativeIterable iterable = variant.value<QAssociativeIterable>(); // 값에 foreach 사용 가능:foreach(const QVariant &v, 이터러블) { qDebug() << v; } // C++11 범위-포 값을 사용할 수 있습니다: for(const QVariant &v: 이터러블) { qDebug() << v; } // 이터레이터 사용 가능: QAssociativeIterable::const_iterator it = iterable.start(); const QAssociativeIterable::const_iterator end = iterable.end(); for ( ; it != end; ++it) { qDebug() << *it; // The current value qDebug() << it.key(); qDebug() << it.value(); } }
컨테이너 자체는 반복하기 전에 복사되지 않습니다.
QVariant 를참조하세요 .
멤버 유형 문서
[alias]
QAssociativeIterable::BidirectionalConstIterator
std::bidirectional_iterator_tag를 사용하여 const_iterator 을 노출합니다.
[alias]
QAssociativeIterable::BidirectionalIterator
std::bidirectional_iterator_tag를 사용하여 이터레이터를 노출합니다.
[alias]
QAssociativeIterable::ForwardConstIterator
std::forward_iterator_tag를 사용하여 const_iterator 를 노출합니다.
[alias]
QAssociativeIterable::ForwardIterator
std::forward_iterator_tag를 사용하여 이터레이터를 노출합니다.
[alias]
QAssociativeIterable::InputConstIterator
std::input_iterator_tag를 사용하여 const_iterator 을 노출합니다.
[alias]
QAssociativeIterable::InputIterator
std::input_iterator_tag를 사용하여 이터레이터를 노출합니다.
[alias]
QAssociativeIterable::RandomAccessConstIterator
std::random_access_iterator_tag를 사용하여 const_iterator 을 노출합니다.
[alias]
QAssociativeIterable::RandomAccessIterator
std::random_access_iterator_tag를 사용하여 이터레이터를 노출합니다.
[alias]
QAssociativeIterable::const_iterator
QAssociativeIterable::const_iterator는 QVariant 에서 컨테이너에 대한 반복을 허용합니다.
QAssociativeIterable::const_iterator는 QAssociativeIterable 인스턴스에 의해서만 생성될 수 있으며, 다른 stl 스타일 이터레이터와 유사한 방식으로 사용할 수 있습니다.
QHash<int, QString> mapping; mapping.insert(7, "Seven"); mapping.insert(11, "Eleven"); mapping.insert(42, "Forty-two");QVariant variant = QVariant::fromValue(mapping);if (variant.canConvert<QVariantHash>()) { QAssociativeIterable iterable = variant.value<QAssociativeIterable>(); // 값에 foreach 사용 가능:foreach(const QVariant &v, 이터러블) { qDebug() << v; } // C++11 범위-포 값을 사용할 수 있습니다: for(const QVariant &v: 이터러블) { qDebug() << v; } // 이터레이터 사용 가능: QAssociativeIterable::const_iterator it = iterable.start(); const QAssociativeIterable::const_iterator end = iterable.end(); for ( ; it != end; ++it) { qDebug() << *it; // The current value qDebug() << it.key(); qDebug() << it.value(); } }
QAssociativeIterable도 참조하세요 .
[alias, since 6.0]
QAssociativeIterable::iterator
QAssociativeIterable::이터레이터는 QVariant 에서 컨테이너에 대한 이터레이션을 허용합니다.
QAssociativeIterable::이터레이터는 QAssociativeIterable 인스턴스에 의해서만 생성될 수 있으며, 다른 stl 스타일 이터레이터와 유사한 방식으로 사용할 수 있습니다.
이 typedef는 Qt 6.0에 도입되었습니다.
QAssociativeIterable 를참조하십시오 .
멤버 함수 문서
bool QAssociativeIterable::containsKey(const QVariant &key)
컨테이너에 지정된 key 항목이 있는 경우 true
, 그렇지 않으면 false
를 반환합니다. key 이 예상 유형으로 변환할 수 없는 경우 false
이 반환됩니다.
QAssociativeIterable::const_iterator QAssociativeIterable::find(const QVariant &key) const
지정된 key 의 요소를 가리키는 const_iterator 또는 해당 키가 없는 경우 컨테이너의 끝을 검색합니다. key 이 예상 유형으로 변환할 수 없는 경우 컨테이너의 끝이 반환됩니다.
void QAssociativeIterable::insertKey(const QVariant &key)
지정된 key 으로 새 항목을 삽입하거나 지정된 key 으로 기존 항목의 매핑된 값을 기본으로 구성된 매핑된 값으로 재설정합니다. key 은 예상 유형으로 강제로 변환됩니다: 변환할 수 없는 경우 기본값이 삽입됩니다.
QAssociativeIterable::iterator QAssociativeIterable::mutableFind(const QVariant &key)
지정된 key 또는 해당 키가 없는 경우 컨테이너의 끝에서 요소를 가리키는 이터레이터를 검색합니다. key 이 예상 유형으로 변환할 수 없는 경우 컨테이너의 끝이 반환됩니다.
void QAssociativeIterable::removeKey(const QVariant &key)
컨테이너에서 key 으로 지정된 항목을 제거합니다. key 은 예상 유형으로 강제로 변환됩니다: 변환할 수 없는 경우 기본값이 제거됩니다.
void QAssociativeIterable::setValue(const QVariant &key, const QVariant &mapped)
key 에 연결된 매핑된 값을 mapped 로 설정합니다(가능하면). 주어진 key 에 대한 항목이 아직 없는 경우 새 항목을 삽입합니다. key 를 키 유형으로 변환할 수 없는 경우 기본으로 구성된 키 유형의 값을 덮어씁니다.
value()도 참조하세요 .
QVariant QAssociativeIterable::value(const QVariant &key) const
지정된 key 에서 매핑된 값을 가져오거나, 키가 없는 경우 매핑된 유형의 기본 구성 QVariant 을 가져옵니다. key 을 키 유형으로 변환할 수 없는 경우 기본적으로 구성된 키와 연결된 매핑된 값이 반환됩니다.
setValue()도 참조하세요 .
© 2025 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.