The QMetaAssociation class allows type erased access to associative containers. 更多...
| 头: |
#include <QMetaAssociation>
|
| CMake: |
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
|
| qmake: |
QT += core
|
| Since: | Qt 6.0 |
| 继承: | QMetaContainer |
此类 相等可比较 .
| 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 |
(从 6.0 起)
QMetaAssociation
|
fromContainer () |
| bool | operator!= (const QMetaAssociation & lhs , const QMetaAssociation & rhs ) |
| bool | operator== (const QMetaAssociation & lhs , const QMetaAssociation & rhs ) |
The class provides a number of primitive container operations, using void* as operands. This way, you can manipulate a generic container retrieved from a Variant without knowing its type.
QMetaAssociation covers both, containers with mapped values such as QMap or QHash , and containers that only hold keys such as QSet .
The void* arguments to the various methods are typically created by using a QVariant of the respective container or value type, and calling its QVariant::data () 或 QVariant::constData () methods. However, you can also pass plain pointers to objects of the container or value type.
Iterator invalidation follows the rules given by the underlying containers and is not expressed in the API. Therefore, for a truly generic container, any iterators should be considered invalid after any write operation.
另请参阅 QMetaContainer , QMetaSequence , QIterable ,和 QIterator .
返回
true
if the container can be queried for keys using
containsKey
(),否则返回
false
.
返回
true
if a const iterator pointing to an entry in the container can be created using
createConstIteratorAtKey
(), otherwise returns false.
返回
true
if an iterator pointing to an entry in the container can be created using
createIteratorAtKey
(), otherwise returns false.
另请参阅 createIteratorAtKey ().
返回
true
if a key can be retrieved from a const iterator using
keyAtConstIterator
(),否则返回
false
.
另请参阅 keyAtConstIterator ().
返回
true
if a key can be retrieved from a non-const iterator using
keyAtIterator
(),否则返回
false
.
另请参阅 keyAtIterator ().
返回
true
if a mapped value can be retrieved from a const iterator using
mappedAtConstIterator
(),否则返回
false
.
另请参阅 mappedAtConstIterator ().
返回
true
if a mapped value can be retrieved from a non-const iterator using
mappedAtIterator
(),否则返回
false
.
另请参阅 mappedAtIterator ().
返回
true
if the container can be queried for values using
mappedAtKey
(),否则返回
false
.
返回
true
if keys can be added to the container using
insertKey
(),否则返回
false
.
另请参阅 insertKey ().
返回
true
if keys can be removed from the container using
removeKey
(),否则返回
false
.
另请参阅 removeKey ().
返回
true
if a mapped value can be set via a non-const iterator using
setMappedAtIterator
(),否则返回
false
.
另请参阅 setMappedAtIterator ().
返回
true
if mapped values can be modified in the container using
setMappedAtKey
(),否则返回
false
.
另请参阅 setMappedAtKey ().
返回
true
若
container
can be queried for keys and contains the
key
,否则返回
false
.
另请参阅 canContainsKey ().
Returns a const iterator pointing to the entry of
key
在
container
, if possible. If the entry doesn't exist, creates a const iterator pointing to the end of the
container
. If no const iterator can be created, returns
nullptr
.
The const iterator has to be destroyed using destroyConstIterator ().
另请参阅 canCreateConstIteratorAtKey (), constBegin (), constEnd (),和 destroyConstIterator ().
Returns a non-const iterator pointing to the entry of
key
在
container
, if possible. If the entry doesn't exist, creates a non-const iterator pointing to the end of the
container
. If no non-const iterator can be created, returns
nullptr
.
The non-const iterator has to be destroyed using destroyIterator ().
另请参阅 canCreateIteratorAtKey (), begin (), end (),和 destroyIterator ().
[static constexpr, since 6.0]
template <typename T>
QMetaAssociation
QMetaAssociation::
fromContainer
()
返回 QMetaAssociation corresponding to the type given as template parameter.
该函数在 Qt 6.0 引入。
插入 key 到 container if possible. If the container has mapped values a default-create mapped value is associated with the key .
另请参阅 canInsertKey ().
Retrieves the key pointed to by the const iterator and stores it in the memory location pointed to by key , if possible.
另请参阅 canGetKeyAtConstIterator (), constBegin (), constEnd (),和 createConstIteratorAtKey ().
Retrieves the key pointed to by the non-const iterator and stores it in the memory location pointed to by key , if possible.
另请参阅 canGetKeyAtIterator (), begin (), end (),和 createIteratorAtKey ().
Returns the meta type for keys in the container.
Retrieves the mapped value pointed to by the const iterator and stores it in the memory location pointed to by mapped , if possible.
另请参阅 canGetMappedAtConstIterator (), constBegin (), constEnd (),和 createConstIteratorAtKey ().
Retrieves the mapped value pointed to by the non-const iterator and stores it in the memory location pointed to by mapped , if possible.
另请参阅 setMappedAtIterator (), canGetMappedAtIterator (), begin (), end (),和 createIteratorAtKey ().
Retrieves the mapped value associated with the key 在 container and places it in the memory location pointed to by mapped , if that is possible.
另请参阅 setMappedAtKey () 和 canGetMappedAtKey ().
Returns the meta type for mapped values in the container.
移除 key and its associated mapped value from the container if possible.
另请参阅 canRemoveKey ().
写入 mapped value to the container location pointed to by the non-const iterator , if possible.
另请参阅 mappedAtIterator (), canSetMappedAtIterator (), begin (), end (),和 createIteratorAtKey ().
Overwrites the value associated with the key 在 container 使用 mapped value passed as argument if that is possible.
另请参阅 mappedAtKey () 和 canSetMappedAtKey ().
[noexcept]
bool
operator!=
(const
QMetaAssociation
&
lhs
, const
QMetaAssociation
&
rhs
)
返回
true
若
QMetaAssociation
lhs
represents a different container type than the
QMetaAssociation
rhs
,否则返回
false
.
[noexcept]
bool
operator==
(const
QMetaAssociation
&
lhs
, const
QMetaAssociation
&
rhs
)
返回
true
若
QMetaAssociation
lhs
represents the same container type as the
QMetaAssociation
rhs
,否则返回
false
.