Struct qt_core::QAssociativeIterable
source · #[repr(C)]pub struct QAssociativeIterable { /* private fields */ }
Expand description
The QAssociativeIterable class is an iterable interface for an associative container in a QVariant.
C++ class: QAssociativeIterable
.
The QAssociativeIterable class is an iterable interface for an associative container in a QVariant.
This class allows several methods of accessing the elements of an associative container held within a QVariant. An instance of QAssociativeIterable can be extracted from a QVariant if it can be converted to a QVariantHash or QVariantMap.
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>(); // Can use foreach over the values: foreach (const QVariant &v, iterable) { qDebug() << v; } // Can use C++11 range-for over the values: for (const QVariant &v : iterable) { qDebug() << v; } // Can use iterators: QAssociativeIterable::const_iterator it = iterable.begin(); const QAssociativeIterable::const_iterator end = iterable.end(); for ( ; it != end; ++it) { qDebug() << *it; // The current value qDebug() << it.key(); qDebug() << it.value(); } }
The container itself is not copied before iterating over it.
Implementations§
source§impl QAssociativeIterable
impl QAssociativeIterable
sourcepub unsafe fn begin(&self) -> CppBox<ConstIterator>
pub unsafe fn begin(&self) -> CppBox<ConstIterator>
Returns a QAssociativeIterable::const_iterator for the beginning of the container. This can be used in stl-style iteration.
Calls C++ function: QAssociativeIterable::const_iterator QAssociativeIterable::begin() const
.
Returns a QAssociativeIterable::const_iterator for the beginning of the container. This can be used in stl-style iteration.
See also end().
sourcepub unsafe fn copy_from(
&self,
other: impl CastInto<Ref<QAssociativeIterable>>
) -> Ref<QAssociativeIterable>
pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QAssociativeIterable>> ) -> Ref<QAssociativeIterable>
The QAssociativeIterable class is an iterable interface for an associative container in a QVariant.
Calls C++ function: QAssociativeIterable& QAssociativeIterable::operator=(const QAssociativeIterable& other)
.
The QAssociativeIterable class is an iterable interface for an associative container in a QVariant.
This class allows several methods of accessing the elements of an associative container held within a QVariant. An instance of QAssociativeIterable can be extracted from a QVariant if it can be converted to a QVariantHash or QVariantMap.
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>(); // Can use foreach over the values: foreach (const QVariant &v, iterable) { qDebug() << v; } // Can use C++11 range-for over the values: for (const QVariant &v : iterable) { qDebug() << v; } // Can use iterators: QAssociativeIterable::const_iterator it = iterable.begin(); const QAssociativeIterable::const_iterator end = iterable.end(); for ( ; it != end; ++it) { qDebug() << *it; // The current value qDebug() << it.key(); qDebug() << it.value(); } }
The container itself is not copied before iterating over it.
sourcepub unsafe fn end(&self) -> CppBox<ConstIterator>
pub unsafe fn end(&self) -> CppBox<ConstIterator>
Returns a QAssociativeIterable::const_iterator for the end of the container. This can be used in stl-style iteration.
Calls C++ function: QAssociativeIterable::const_iterator QAssociativeIterable::end() const
.
Returns a QAssociativeIterable::const_iterator for the end of the container. This can be used in stl-style iteration.
See also begin().
sourcepub unsafe fn find(
&self,
key: impl CastInto<Ref<QVariant>>
) -> CppBox<ConstIterator>
pub unsafe fn find( &self, key: impl CastInto<Ref<QVariant>> ) -> CppBox<ConstIterator>
Returns a QAssociativeIterable::const_iterator for the given key key in the container, if the types are convertible.
Calls C++ function: QAssociativeIterable::const_iterator QAssociativeIterable::find(const QVariant& key) const
.
Returns a QAssociativeIterable::const_iterator for the given key key in the container, if the types are convertible.
If the key is not found, returns end().
This can be used in stl-style iteration.
This function was introduced in Qt 5.5.
sourcepub unsafe fn new_copy(
other: impl CastInto<Ref<QAssociativeIterable>>
) -> CppBox<QAssociativeIterable>
pub unsafe fn new_copy( other: impl CastInto<Ref<QAssociativeIterable>> ) -> CppBox<QAssociativeIterable>
The QAssociativeIterable class is an iterable interface for an associative container in a QVariant.
Calls C++ function: [constructor] void QAssociativeIterable::QAssociativeIterable(const QAssociativeIterable& other)
.
The QAssociativeIterable class is an iterable interface for an associative container in a QVariant.
This class allows several methods of accessing the elements of an associative container held within a QVariant. An instance of QAssociativeIterable can be extracted from a QVariant if it can be converted to a QVariantHash or QVariantMap.
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>(); // Can use foreach over the values: foreach (const QVariant &v, iterable) { qDebug() << v; } // Can use C++11 range-for over the values: for (const QVariant &v : iterable) { qDebug() << v; } // Can use iterators: QAssociativeIterable::const_iterator it = iterable.begin(); const QAssociativeIterable::const_iterator end = iterable.end(); for ( ; it != end; ++it) { qDebug() << *it; // The current value qDebug() << it.key(); qDebug() << it.value(); } }
The container itself is not copied before iterating over it.
sourcepub unsafe fn size(&self) -> c_int
pub unsafe fn size(&self) -> c_int
Returns the number of elements in the container.
Calls C++ function: int QAssociativeIterable::size() const
.
Returns the number of elements in the container.
sourcepub unsafe fn value(
&self,
key: impl CastInto<Ref<QVariant>>
) -> CppBox<QVariant>
pub unsafe fn value( &self, key: impl CastInto<Ref<QVariant>> ) -> CppBox<QVariant>
Returns the value for the given key in the container, if the types are convertible.
Calls C++ function: QVariant QAssociativeIterable::value(const QVariant& key) const
.
Returns the value for the given key in the container, if the types are convertible.
See also find().
Trait Implementations§
source§impl Begin for QAssociativeIterable
impl Begin for QAssociativeIterable
source§unsafe fn begin(&self) -> CppBox<ConstIterator>
unsafe fn begin(&self) -> CppBox<ConstIterator>
Returns a QAssociativeIterable::const_iterator for the beginning of the container. This can be used in stl-style iteration.
Calls C++ function: QAssociativeIterable::const_iterator QAssociativeIterable::begin() const
.
Returns a QAssociativeIterable::const_iterator for the beginning of the container. This can be used in stl-style iteration.
See also end().
§type Output = CppBox<ConstIterator>
type Output = CppBox<ConstIterator>
source§impl CppDeletable for QAssociativeIterable
impl CppDeletable for QAssociativeIterable
source§unsafe fn delete(&self)
unsafe fn delete(&self)
The QAssociativeIterable class is an iterable interface for an associative container in a QVariant.
Calls C++ function: [destructor] void QAssociativeIterable::~QAssociativeIterable()
.
The QAssociativeIterable class is an iterable interface for an associative container in a QVariant.
This class allows several methods of accessing the elements of an associative container held within a QVariant. An instance of QAssociativeIterable can be extracted from a QVariant if it can be converted to a QVariantHash or QVariantMap.
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>(); // Can use foreach over the values: foreach (const QVariant &v, iterable) { qDebug() << v; } // Can use C++11 range-for over the values: for (const QVariant &v : iterable) { qDebug() << v; } // Can use iterators: QAssociativeIterable::const_iterator it = iterable.begin(); const QAssociativeIterable::const_iterator end = iterable.end(); for ( ; it != end; ++it) { qDebug() << *it; // The current value qDebug() << it.key(); qDebug() << it.value(); } }
The container itself is not copied before iterating over it.
source§impl End for QAssociativeIterable
impl End for QAssociativeIterable
source§unsafe fn end(&self) -> CppBox<ConstIterator>
unsafe fn end(&self) -> CppBox<ConstIterator>
Returns a QAssociativeIterable::const_iterator for the end of the container. This can be used in stl-style iteration.
Calls C++ function: QAssociativeIterable::const_iterator QAssociativeIterable::end() const
.
Returns a QAssociativeIterable::const_iterator for the end of the container. This can be used in stl-style iteration.
See also begin().