QMetaSequence 类允许类型擦除对顺序容器的访问。 更多...
头: | #include <QMetaSequence> |
CMake: |
find_package(Qt6 COMPONENTS Core REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
Since: | Qt 6.0 |
继承: | QMetaContainer |
void | addValue (void * container , const void * value ) const |
void | addValueAtBegin (void * container , const void * value ) const |
void | addValueAtEnd (void * container , const void * value ) const |
bool | canAddValue () const |
bool | canAddValueAtBegin () const |
bool | canAddValueAtEnd () const |
bool | canEraseRangeAtIterator () const |
bool | canEraseValueAtIterator () const |
bool | canGetValueAtConstIterator () const |
bool | canGetValueAtIndex () const |
bool | canGetValueAtIterator () const |
bool | canInsertValueAtIterator () const |
bool | canRemoveValue () const |
bool | canRemoveValueAtBegin () const |
bool | canRemoveValueAtEnd () const |
bool | canSetValueAtIndex () const |
bool | canSetValueAtIterator () const |
void | eraseRangeAtIterator (void * container , const void * iterator1 , const void * iterator2 ) const |
void | eraseValueAtIterator (void * container , const void * iterator ) const |
void | insertValueAtIterator (void * container , const void * iterator , const void * value ) const |
bool | isSortable () const |
void | removeValue (void * container ) const |
void | removeValueAtBegin (void * container ) const |
void | removeValueAtEnd (void * container ) const |
void | setValueAtIndex (void * container , qsizetype index , const void * value ) const |
void | setValueAtIterator (const void * iterator , const void * value ) const |
void | valueAtConstIterator (const void * iterator , void * result ) const |
void | valueAtIndex (const void * container , qsizetype index , void * result ) const |
void | valueAtIterator (const void * iterator , void * result ) const |
QMetaType | valueMetaType () const |
QMetaSequence | fromContainer () |
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.
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.
添加
value
到
container
if possible. If
canAddValue
() 返回
false
,
value
is not added. Else, if
canAddValueAtEnd
() 返回
true
,
value
is added to the end of the
container
. Else, if
canAddValueAtBegin
() 返回
true
,
value
is added to the beginning of the container. Else, the value is added in an unspecified place or not at all. The latter is the case for adding values to an unordered container, for example
QSet
.
另请参阅 canAddValue (), canAddValueAtBegin (), canAddValueAtEnd (), isSortable (),和 removeValue ().
添加
value
to the beginning of
container
if possible. If
canAddValueAtBegin
() 返回
false
,
value
is not added.
另请参阅 canAddValueAtBegin (), isSortable (),和 removeValueAtBegin ().
添加
value
to the end of
container
if possible. If
canAddValueAtEnd
() 返回
false
,
value
is not added.
另请参阅 canAddValueAtEnd (), isSortable (),和 removeValueAtEnd ().
返回
true
if values can be added to the container,
false
否则。
另请参阅 addValue () 和 isSortable ().
返回
true
if values added using
addValue
() can be placed at the beginning of the container, otherwise returns
false
.
另请参阅 addValueAtBegin () 和 canAddValueAtEnd ().
返回
true
if values added using
addValue
() can be placed at the end of the container, otherwise returns
false
.
另请参阅 addValueAtEnd () 和 canAddValueAtBegin ().
返回
true
if a range between two iterators can be erased from the container,
false
否则。
返回
true
if the value pointed to by a non-const iterator can be erased,
false
否则。
另请参阅 hasIterator () 和 eraseValueAtIterator ().
返回
true
if the underlying container can retrieve the value pointed to by a const iterator,
false
否则。
另请参阅 hasConstIterator () 和 valueAtConstIterator ().
返回
true
if values can be retrieved from the container by index, otherwise
false
.
另请参阅 valueAtIndex ().
返回
true
if the underlying container can retrieve the value pointed to by a non-const iterator,
false
否则。
另请参阅 hasIterator () 和 valueAtIterator ().
返回
true
if the underlying container can insert a new value, taking the location pointed to by a non-const iterator into account.
另请参阅 hasIterator () 和 insertValueAtIterator ().
返回
true
if values can be removed from the container,
false
否则。
另请参阅 removeValue () 和 isSortable ().
返回
true
if values can be removed from the beginning of the container using
removeValue
() can be placed at the, otherwise returns
false
.
另请参阅 removeValueAtBegin () 和 canRemoveValueAtEnd ().
返回
true
if values can be removed from the end of the container using
removeValue
() can be placed at the, otherwise returns
false
.
另请参阅 removeValueAtEnd () 和 canRemoveValueAtBegin ().
返回
true
if an value can be written to the container by index, otherwise
false
.
另请参阅 setValueAtIndex ().
返回
true
if the underlying container can write to the value pointed to by a non-const iterator,
false
否则。
另请参阅 hasIterator () 和 setValueAtIterator ().
Erases the range of values between the iterators iterator1 and iterator2 从 container , if possible.
另请参阅 canEraseValueAtIterator (), begin (),和 end ().
Erases the value pointed to by the non-const iterator 从 container , if possible.
另请参阅 canEraseValueAtIterator (), begin (),和 end ().
[static, since 6.0]
template <typename T>
QMetaSequence
QMetaSequence::
fromContainer
()
返回 QMetaSequence corresponding to the type given as template parameter.
该函数在 Qt 6.0 引入。
插入
value
到
container
, if possible, taking the non-const
iterator
into account. If
canInsertValueAtIterator
() 返回
false
,
value
is not inserted. Else if
isSortable
() 返回
true
, the value is inserted before the value pointed to by
iterator
. Else, the
value
is inserted at an unspecified place or not at all. In the latter case, the
iterator
is taken as a hint. If it points to the correct place for the
value
, the operation may be faster than a
addValue
() without iterator.
另请参阅 canInsertValueAtIterator (), isSortable (), begin (),和 end ().
返回
true
if the underlying container is sortable, otherwise returns
false
. A container is considered sortable if values added to it are placed in a defined location. Inserting into or adding to a sortable container will always succeed. Inserting into or adding to an unsortable container may not succeed, for example if the container is a
QSet
that already contains the value being inserted.
另请参阅 addValue (), insertValueAtIterator (), canAddValueAtBegin (), canAddValueAtEnd (), canRemoveValueAtBegin (),和 canRemoveValueAtEnd ().
Removes an value from the
container
if possible. If
canRemoveValue
() 返回
false
, no value is removed. Else, if
canRemoveValueAtEnd
() 返回
true
, the last value in the
container
is removed. Else, if
canRemoveValueAtBegin
() 返回
true
, the first value in the
container
is removed. Else, an unspecified value or nothing is removed.
另请参阅 canRemoveValue (), canRemoveValueAtBegin (), canRemoveValueAtEnd (), isSortable (),和 addValue ().
Removes a value from the beginning of
container
if possible. If
canRemoveValueAtBegin
() 返回
false
, the value is not removed.
另请参阅 canRemoveValueAtBegin (), isSortable (),和 addValueAtBegin ().
Removes a value from the end of
container
if possible. If
canRemoveValueAtEnd
() 返回
false
, the value is not removed.
另请参阅 canRemoveValueAtEnd (), isSortable (),和 addValueAtEnd ().
Overwrites the value at index 在 container 使用 value passed as parameter if that is possible.
另请参阅 valueAtIndex () 和 canSetValueAtIndex ().
写入 value to the value pointed to by the non-const iterator , if possible.
另请参阅 valueAtIterator (), canSetValueAtIterator (), begin (),和 end ().
Retrieves the value pointed to by the const iterator and stores it in the memory location pointed to by result , if possible.
另请参阅 canGetValueAtConstIterator (), constBegin (),和 constEnd ().
Retrieves the value at index 在 container and places it in the memory location pointed to by result , if that is possible.
另请参阅 setValueAtIndex () 和 canGetValueAtIndex ().
Retrieves the value pointed to by the non-const iterator and stores it in the memory location pointed to by result , if possible.
另请参阅 setValueAtIterator (), canGetValueAtIterator (), begin (),和 end ().
Returns the meta type for values stored in the container.