QList Class | Qt Core (original) (raw)

Member Function Documentation

[since 6.0] void QList::resize(qsizetype size)

[since 6.0] void QList::resize(qsizetype size, QList<T>::parameter_type c)

Sets the size of the list to size. If size is greater than the current size, elements are added to the end; the new elements are initialized with either a default-constructed value or c. If size is less than the current size, elements are removed from the end.

If this list is not shared, the capacity() is preserved. Use squeeze() to shed excess capacity.

Note: In Qt versions prior to 5.7 (for QVector; QList lacked a resize() until 6.0), this function released the memory used by the list instead of preserving the capacity.

This function was introduced in Qt 6.0.

See also size().

void QList::prepend(QList<T>::parameter_type value)

void QList::prepend(QList<T>::rvalue_ref value)

Inserts value at the beginning of the list.

Example:

QList<QString> list; list.prepend("one"); list.prepend("two"); list.prepend("three"); // list: ["three", "two", "one"]

This is the same as list.insert(0, value).

Normally this operation is relatively fast (amortized constant time). QList is able to allocate extra memory at the beginning of the list data and grow in that direction without reallocating or moving the data on each operation. However if you want a container class with a guarantee of constant time prepend, use std::list instead, but prefer QList otherwise.

See also append() and insert().

template <typename... Args> QList<T>::reference QList::emplaceBack(Args &&... args)

template <typename... Args> QList<T>::reference QList::emplace_back(Args &&... args)

Adds a new element to the end for the container. This new element is constructed in-place using args as the arguments for its construction.

Returns a reference to the new element.

Example:

QList<QString> list{"one", "two"}; list.emplaceBack(3, 'a'); qDebug() << list; // list: ["one", "two", "aaa"]

It is also possible to access a newly created object by using returned reference:

QList<QString> list; auto &ref = list.emplaceBack(); ref = "one"; // list: ["one"]

This is the same as list.emplace(list.size(), args).

See also emplace.

QList<T>::iterator QList::insert(qsizetype i, QList<T>::parameter_type value)

QList<T>::iterator QList::insert(qsizetype i, QList<T>::rvalue_ref value)

Inserts value at index position i in the list. If i is 0, the value is prepended to the list. If i is size(), the value is appended to the list.

Example:

QList<QString> list = {"alpha", "beta", "delta"}; list.insert(2, "gamma"); // list: ["alpha", "beta", "gamma", "delta"]

For large lists, this operation can be slow (linear time), because it requires moving all the items at indexes i and above by one position further in memory. If you want a container class that provides a fast insert() function, use std::list instead.

See also append(), prepend(), and remove().

QList<T>::iterator QList::insert(QList<T>::const_iterator before, QList<T>::parameter_type value)

QList<T>::iterator QList::insert(QList<T>::const_iterator before, QList<T>::rvalue_ref value)

This is an overloaded function.

Inserts value in front of the item pointed to by the iterator before. Returns an iterator pointing at the inserted item.

void QList::replace(qsizetype i, QList<T>::parameter_type value)

void QList::replace(qsizetype i, QList<T>::rvalue_ref value)

Replaces the item at index position i with value.

i must be a valid index position in the list (i.e., 0 <= i < size()).

See also operator[]() and remove().

void QList::push_front(QList<T>::parameter_type value)

void QList::push_front(QList<T>::rvalue_ref value)

This function is provided for STL compatibility. It is equivalent to prepend(value).

[static constexpr, since 6.8] qsizetype QList::maxSize()

[constexpr noexcept, since 6.8] qsizetype QList::max_size() const

It returns the maximum number of elements that the list can theoretically hold. In practice, the number can be much smaller, limited by the amount of memory available to the system.

This function was introduced in Qt 6.8.

QList<T> QList::operator+(QList<T> &&other) &&

QList<T> QList::operator+(const QList<T> &other) &&

QList<T> QList::operator+(QList<T> &&other) const &

QList<T> QList::operator+(const QList<T> &other) const &

Returns a list that contains all the items in this list followed by all the items in the other list.

See also operator+=().

[constexpr noexcept] QList::QList()

Constructs an empty list.

See also resize().

[explicit] QList::QList(qsizetype size)

Constructs a list with an initial size of size elements.

The elements are initialized with a default-constructed value.

See also resize().

QList::QList(std::initializer_list<T> args)

Constructs a list from the std::initializer_list given by args.

template <typename InputIterator, QList::if_input_iterator = true> QList::QList(InputIterator first, InputIterator last)

Constructs a list with the contents in the iterator range [first, last).

The value type of InputIterator must be convertible to T.

Constraints

Participates in overload resolution only if InputIterator meets the requirements of a LegacyInputIterator.

QList::QList(qsizetype size, QList<T>::parameter_type value)

Constructs a list with an initial size of size elements. Each element is initialized with value.

See also resize() and fill().

[since 6.8] QList::QList(qsizetype size, Qt::Initialization)

Constructs a list with an initial size of size elements.

QList will make an attempt at not initializing the elements.

Specifically:

This function was introduced in Qt 6.8.

See also resizeForOverwrite().

[default] QList::QList(const QList<T> &other)

Constructs a copy of other.

This operation takes constant time, because QList is implicitly shared. This makes returning a QList from a function very fast. If a shared instance is modified, it will be copied (copy-on-write), and that takes linear time.

See also operator=().

[default] QList::QList(QList<T> &&other)

Move-constructs a QList instance, making it point at the same object that other was pointing to.

[default] QList::~QList()

Destroys the list.

void QList::append(QList<T>::parameter_type value)

Inserts value at the end of the list.

Example:

QList<QString> list; list.append("one"); list.append("two"); QString three = "three"; list.append(three); // list: ["one", "two", "three"] // three: "three"

This is the same as calling resize(size() + 1) and assigning value to the new last element in the list.

This operation is relatively fast, because QList typically allocates more memory than necessary, so it can grow without reallocating the entire list each time.

See also operator<<(), prepend(), and insert().

[since 6.0] void QList::append(QList<T> &&value)

This is an overloaded function.

Moves the items of the value list to the end of this list.

This function was introduced in Qt 6.0.

See also operator<<() and operator+=().

void QList::append(QList<T>::rvalue_ref value)

This is an overloaded function.

Example:

QList<QString> list; list.append("one"); list.append("two"); QString three = "three"; list.append(std::move(three)); // list: ["one", "two", "three"] // three: ""

void QList::append(const QList<T> &value)

This is an overloaded function.

Appends the items of the value list to this list.

See also operator<<() and operator+=().

[since 6.6] QList<T> &QList::assign(std::initializer_list<T> l)

Replaces the contents of this list with a copy of the elements of l.

The size of this list will be equal to the number of elements in l.

This function only allocates memory if the number of elements in l exceeds the capacity of this list or this list is shared.

This function was introduced in Qt 6.6.

[since 6.6] template <typename InputIterator, QList::if_input_iterator = true> QList<T> &QList::assign(InputIterator first, InputIterator last)

Replaces the contents of this list with a copy of the elements in the iterator range [first, last).

The size of this list will be equal to the number of elements in the range [first, last).

This function will only allocate memory if the number of elements in the range exceeds the capacity of this list or this list is shared.

Note: The behavior is undefined if either argument is an iterator into *this.

Constraints

Participates in overload resolution only if InputIterator meets the requirements of a LegacyInputIterator.

This function was introduced in Qt 6.6.

[since 6.6] QList<T> &QList::assign(qsizetype n, QList<T>::parameter_type t)

Replaces the contents of this list with n copies of t.

The size of this list will be equal to n.

This function will only allocate memory if n exceeds the capacity of the list or this list is shared.

This function was introduced in Qt 6.6.

[noexcept] QList<T>::const_reference QList::at(qsizetype i) const

Returns the item at index position i in the list.

i must be a valid index position in the list (i.e., 0 <= i < size()).

See also value() and operator[]().

QList<T>::reference QList::back()

This function is provided for STL compatibility. It is equivalent to last().

[noexcept] QList<T>::const_reference QList::back() const

This is an overloaded function.

QList<T>::iterator QList::begin()

Returns an STL-style iterator pointing to the first item in the list.

Warning: The returned iterator is invalidated on detachment or when the QList is modified.

See also constBegin() and end().

[noexcept] QList<T>::const_iterator QList::begin() const

This is an overloaded function.

qsizetype QList::capacity() const

Returns the maximum number of items that can be stored in the list without forcing a reallocation.

The sole purpose of this function is to provide a means of fine tuning QList's memory usage. In general, you will rarely ever need to call this function. If you want to know how many items are in the list, call size().

Note: a statically allocated list will report a capacity of 0, even if it's not empty.

Warning: The free space position in the allocated memory block is undefined. In other words, you should not assume that the free memory is always located at the end of the list. You can call reserve() to ensure that there is enough space at the end.

See also reserve() and squeeze().

[noexcept] QList<T>::const_iterator QList::cbegin() const

Returns a const STL-style iterator pointing to the first item in the list.

Warning: The returned iterator is invalidated on detachment or when the QList is modified.

See also begin() and cend().

[noexcept] QList<T>::const_iterator QList::cend() const

Returns a const STL-style iterator pointing just after the last item in the list.

Warning: The returned iterator is invalidated on detachment or when the QList is modified.

See also cbegin() and end().

void QList::clear()

Removes all the elements from the list.

If this list is not shared, the capacity() is preserved. Use squeeze() to shed excess capacity.

Note: In Qt versions prior to 5.7 (for QVector) and 6.0 (for QList), this function released the memory used by the list instead of preserving the capacity.

See also resize() and squeeze().

[noexcept] QList<T>::const_iterator QList::constBegin() const

Returns a const STL-style iterator pointing to the first item in the list.

Warning: The returned iterator is invalidated on detachment or when the QList is modified.

See also begin() and constEnd().

[noexcept] QList<T>::const_pointer QList::constData() const

Returns a const pointer to the data stored in the list. The pointer can be used to access the items in the list.

Warning: The pointer is invalidated on detachment or when the QList is modified.

This function is mostly useful to pass a list to a function that accepts a plain C++ array.

See also data() and operator[]().

[noexcept] QList<T>::const_iterator QList::constEnd() const

Returns a const STL-style iterator pointing just after the last item in the list.

Warning: The returned iterator is invalidated on detachment or when the QList is modified.

See also constBegin() and end().

[noexcept] const T &QList::constFirst() const

Returns a const reference to the first item in the list. This function assumes that the list isn't empty.

See also constLast(), isEmpty(), and first().

[noexcept] const T &QList::constLast() const

Returns a const reference to the last item in the list. This function assumes that the list isn't empty.

See also constFirst(), isEmpty(), and last().

[noexcept] template bool QList::contains(const AT &value) const

Returns true if the list contains an occurrence of value; otherwise returns false.

This function requires the value type to have an implementation of operator==().

See also indexOf() and count().

[noexcept] template qsizetype QList::count(const AT &value) const

Returns the number of occurrences of value in the list.

This function requires the value type to have an implementation of operator==().

See also contains() and indexOf().

[noexcept] qsizetype QList::count() const

This is an overloaded function.

Same as size().

[noexcept] QList<T>::const_reverse_iterator QList::crbegin() const

Returns a const STL-style reverse iterator pointing to the first item in the list, in reverse order.

Warning: The returned iterator is invalidated on detachment or when the QList is modified.

See also begin(), rbegin(), and rend().

[noexcept] QList<T>::const_reverse_iterator QList::crend() const

Returns a const STL-style reverse iterator pointing just after the last item in the list, in reverse order.

Warning: The returned iterator is invalidated on detachment or when the QList is modified.

See also end(), rend(), and rbegin().

QList<T>::pointer QList::data()

Returns a pointer to the data stored in the list. The pointer can be used to access and modify the items in the list.

Example:

QList list(10); int *data = list.data(); for (qsizetype i = 0; i < 10; ++i) data[i] = 2 * i;

Warning: The pointer is invalidated on detachment or when the QList is modified.

This function is mostly useful to pass a list to a function that accepts a plain C++ array.

See also constData() and operator[]().

[noexcept] QList<T>::const_pointer QList::data() const

This is an overloaded function.

template <typename... Args> QList<T>::iterator QList::emplace(qsizetype i, Args &&... args)

Extends the container by inserting a new element at position i. This new element is constructed in-place using args as the arguments for its construction.

Returns an iterator to the new element.

Example:

QList<QString> list{"a", "ccc"}; list.emplace(1, 2, 'b'); // list: ["a", "bb", "ccc"]

Note: It is guaranteed that the element will be created in place at the beginning, but after that it might be copied or moved to the right position.

See also emplaceBack.

template <typename... Args> QList<T>::iterator QList::emplace(QList<T>::const_iterator before, Args &&... args)

This is an overloaded function.

Creates a new element in front of the item pointed to by the iterator before. This new element is constructed in-place using args as the arguments for its construction.

Returns an iterator to the new element.

[noexcept] bool QList::empty() const

This function is provided for STL compatibility. It is equivalent to isEmpty(), returning true if the list is empty; otherwise returns false.

QList<T>::iterator QList::end()

Returns an STL-style iterator pointing just after the last item in the list.

Warning: The returned iterator is invalidated on detachment or when the QList is modified.

See also begin() and constEnd().

[noexcept] QList<T>::const_iterator QList::end() const

This is an overloaded function.

bool QList::endsWith(QList<T>::parameter_type value) const

Returns true if this list is not empty and its last item is equal to value; otherwise returns false.

See also isEmpty() and last().

QList<T>::iterator QList::erase(QList<T>::const_iterator pos)

Removes the item pointed to by the iterator pos from the list, and returns an iterator to the next item in the list (which may be end()).

Element removal will preserve the list's capacity and not reduce the amount of allocated memory. To shed extra capacity and free as much memory as possible, call squeeze().

Note: When QList is not implicitly shared, this function only invalidates iterators at or after the specified position.

See also insert() and remove().

QList<T>::iterator QList::erase(QList<T>::const_iterator begin, QList<T>::const_iterator end)

This is an overloaded function.

Removes all the items from begin up to (but not including) end. Returns an iterator to the same item that end referred to before the call.

Element removal will preserve the list's capacity and not reduce the amount of allocated memory. To shed extra capacity and free as much memory as possible, call squeeze().

Note: When QList is not implicitly shared, this function only invalidates iterators at or after the specified position.

QList<T> &QList::fill(QList<T>::parameter_type value, qsizetype size = -1)

Assigns value to all items in the list. If size is different from -1 (the default), the list is resized to size beforehand.

Example:

QList<QString> list(3); list.fill("Yes"); // list: ["Yes", "Yes", "Yes"]

list.fill("oh", 5); // list: ["oh", "oh", "oh", "oh", "oh"]

See also resize().

T &QList::first()

Returns a reference to the first item in the list. This function assumes that the list isn't empty.

See also last(), isEmpty(), and constFirst().

[since 6.0] QList<T> QList::first(qsizetype n) const

Returns a sub-list that contains the first n elements of this list.

Note: The behavior is undefined when n < 0 or _n_ > size().

This function was introduced in Qt 6.0.

See also last() and sliced().

[noexcept] const T &QList::first() const

This is an overloaded function.

QList<T>::reference QList::front()

This function is provided for STL compatibility. It is equivalent to first().

[noexcept] QList<T>::const_reference QList::front() const

This is an overloaded function.

[noexcept] template qsizetype QList::indexOf(const AT &value, qsizetype from = 0) const

Returns the index position of the first occurrence of value in the list, searching forward from index position from. Returns -1 if no item matched.

Example:

QList<QString> list{"A", "B", "C", "B", "A"}; list.indexOf("B"); // returns 1 list.indexOf("B", 1); // returns 1 list.indexOf("B", 2); // returns 3 list.indexOf("X"); // returns -1

This function requires the value type to have an implementation of operator==().

See also lastIndexOf() and contains().

QList<T>::iterator QList::insert(QList<T>::const_iterator before, qsizetype count, QList<T>::parameter_type value)

Inserts count copies of value in front of the item pointed to by the iterator before. Returns an iterator pointing at the first of the inserted items.

QList<T>::iterator QList::insert(qsizetype i, qsizetype count, QList<T>::parameter_type value)

This is an overloaded function.

Inserts count copies of value at index position i in the list.

Example:

QList list = {2.718, 1.442, 0.4342}; list.insert(1, 3, 9.9); // list: [2.718, 9.9, 9.9, 9.9, 1.442, 0.4342]

[noexcept] bool QList::isEmpty() const

Returns true if the list has size 0; otherwise returns false.

See also size() and resize().

T &QList::last()

Returns a reference to the last item in the list. This function assumes that the list isn't empty.

See also first(), isEmpty(), and constLast().

[since 6.0] QList<T> QList::last(qsizetype n) const

Returns a sub-list that contains the last n elements of this list.

Note: The behavior is undefined when n < 0 or _n_ > size().

This function was introduced in Qt 6.0.

See also first() and sliced().

[noexcept] const T &QList::last() const

This is an overloaded function.

[noexcept] template qsizetype QList::lastIndexOf(const AT &value, qsizetype from = -1) const

Returns the index position of the last occurrence of the value value in the list, searching backward from index position from. If from is -1 (the default), the search starts at the last item. Returns -1 if no item matched.

Example:

QList<QString> list = {"A", "B", "C", "B", "A"}; list.lastIndexOf("B"); // returns 3 list.lastIndexOf("B", 3); // returns 3 list.lastIndexOf("B", 2); // returns 1 list.lastIndexOf("X"); // returns -1

This function requires the value type to have an implementation of operator==().

See also indexOf().

[noexcept] qsizetype QList::length() const

Same as size() and count().

See also size() and count().

QList<T> QList::mid(qsizetype pos, qsizetype length = -1) const

Returns a sub-list which contains elements from this list, starting at position pos. If length is -1 (the default), all elements after pos are included; otherwise length elements (or all remaining elements if there are less than length elements) are included.

void QList::move(qsizetype from, qsizetype to)

Moves the item at index position from to index position to.

from and to must be within bounds.

For example, to move the first item to the end of the list:

QList list = {1, 2, 3}; list.move(0, list.size() - 1); qDebug() << list; // Prints "QList(2, 3, 1)"

[noexcept] void QList::pop_back()

This function is provided for STL compatibility. It is equivalent to removeLast().

[noexcept] void QList::pop_front()

This function is provided for STL compatibility. It is equivalent to removeFirst().

void QList::push_back(QList<T>::parameter_type value)

This function is provided for STL compatibility. It is equivalent to append(value).

void QList::push_back(QList<T>::rvalue_ref value)

This is an overloaded function.

QList<T>::reverse_iterator QList::rbegin()

Returns a STL-style reverse iterator pointing to the first item in the list, in reverse order.

Warning: The returned iterator is invalidated on detachment or when the QList is modified.

See also begin(), crbegin(), and rend().

[noexcept] QList<T>::const_reverse_iterator QList::rbegin() const

This is an overloaded function.

void QList::remove(qsizetype i, qsizetype n = 1)

Removes n elements from the list, starting at index position i.

Element removal will preserve the list's capacity and not reduce the amount of allocated memory. To shed extra capacity and free as much memory as possible, call squeeze().

Note: When QList is not implicitly shared, this function only invalidates iterators at or after the specified position.

See also insert(), replace(), and fill().

template qsizetype QList::removeAll(const AT &t)

Removes all elements that compare equal to t from the list. Returns the number of elements removed, if any.

Element removal will preserve the list's capacity and not reduce the amount of allocated memory. To shed extra capacity and free as much memory as possible, call squeeze().

See also removeOne().

void QList::removeAt(qsizetype i)

Removes the element at index position i. Equivalent to

Element removal will preserve the list's capacity and not reduce the amount of allocated memory. To shed extra capacity and free as much memory as possible, call squeeze().

Note: When QList is not implicitly shared, this function only invalidates iterators at or after the specified position.

See also remove().

[noexcept] void QList::removeFirst()

Removes the first item in the list. Calling this function is equivalent to calling remove(0). The list must not be empty. If the list can be empty, call isEmpty() before calling this function.

Element removal will preserve the list's capacity and not reduce the amount of allocated memory. To shed extra capacity and free as much memory as possible, call squeeze().

See also remove(), takeFirst(), and isEmpty().

[since 6.1] template qsizetype QList::removeIf(Predicate pred)

Removes all elements for which the predicate pred returns true from the list. Returns the number of elements removed, if any.

This function was introduced in Qt 6.1.

See also removeAll().

[noexcept] void QList::removeLast()

Removes the last item in the list. Calling this function is equivalent to calling remove(size() - 1). The list must not be empty. If the list can be empty, call isEmpty() before calling this function.

Element removal will preserve the list's capacity and not reduce the amount of allocated memory. To shed extra capacity and free as much memory as possible, call squeeze().

See also remove(), takeLast(), removeFirst(), and isEmpty().

template bool QList::removeOne(const AT &t)

Removes the first element that compares equal to t from the list. Returns whether an element was, in fact, removed.

Element removal will preserve the list's capacity and not reduce the amount of allocated memory. To shed extra capacity and free as much memory as possible, call squeeze().

See also removeAll().

QList<T>::reverse_iterator QList::rend()

Returns a STL-style reverse iterator pointing just after the last item in the list, in reverse order.

Warning: The returned iterator is invalidated on detachment or when the QList is modified.

See also end(), crend(), and rbegin().

[noexcept] QList<T>::const_reverse_iterator QList::rend() const

This is an overloaded function.

void QList::reserve(qsizetype size)

Attempts to allocate memory for at least size elements.

If you know in advance how large the list will be, you should call this function to prevent reallocations and memory fragmentation. If you resize the list often, you are also likely to get better performance.

If in doubt about how much space shall be needed, it is usually better to use an upper bound as size, or a high estimate of the most likely size, if a strict upper bound would be much bigger than this. If size is an underestimate, the list will grow as needed once the reserved size is exceeded, which may lead to a larger allocation than your best overestimate would have and will slow the operation that triggers it.

Warning: reserve() reserves memory but does not change the size of the list. Accessing data beyond the current end of the list is undefined behavior. If you need to access memory beyond the current end of the list, use resize().

See also squeeze(), capacity(), and resize().

[since 6.8] void QList::resizeForOverwrite(qsizetype size)

Sets the size of the list to size. If size is less than the current size, elements are removed from the end. If size is greater than the current size, elements are added to the end; QList will make an attempt at not initializing these new elements.

Specifically:

This function was introduced in Qt 6.8.

void QList::shrink_to_fit()

This function is provided for STL compatibility. It is equivalent to squeeze().

[noexcept] qsizetype QList::size() const

Returns the number of items in the list.

See also isEmpty() and resize().

[since 6.0] QList<T> QList::sliced(qsizetype pos, qsizetype n) const

Returns a sub-list that contains n elements of this list, starting at position pos.

Note: The behavior is undefined when pos < 0, _n_ < 0, or _pos_ + _n_ > size().

This function was introduced in Qt 6.0.

See also first() and last().

[since 6.0] QList<T> QList::sliced(qsizetype pos) const

This is an overloaded function.

Returns a sub-list that contains the elements of this list starting at position pos and extending to its end.

Note: The behavior is undefined when pos < 0 or _pos_ > size().

This function was introduced in Qt 6.0.

See also first() and last().

void QList::squeeze()

Releases any memory not required to store the items.

The sole purpose of this function is to provide a means of fine tuning QList's memory usage. In general, you will rarely ever need to call this function.

See also reserve() and capacity().

bool QList::startsWith(QList<T>::parameter_type value) const

Returns true if this list is not empty and its first item is equal to value; otherwise returns false.

See also isEmpty() and first().

[noexcept] void QList::swap(QList<T> &other)

Swaps this list with other. This operation is very fast and never fails.

void QList::swapItemsAt(qsizetype i, qsizetype j)

Exchange the item at index position i with the item at index position j. This function assumes that both i and j are at least 0 but less than size(). To avoid failure, test that both i and j are at least 0 and less than size().

T QList::takeAt(qsizetype i)

Removes the element at index position i and returns it.

Equivalent to

T t = at(i); remove(i); return t;

Note: When QList is not implicitly shared, this function only invalidates iterators at or after the specified position.

See also takeFirst() and takeLast().

QList<T>::value_type QList::takeFirst()

Removes the first item in the list and returns it. This function assumes the list is not empty. To avoid failure, call isEmpty() before calling this function.

See also takeLast() and removeFirst().

QList<T>::value_type QList::takeLast()

Removes the last item in the list and returns it. This function assumes the list is not empty. To avoid failure, call isEmpty() before calling this function.

If you don't use the return value, removeLast() is more efficient.

See also takeFirst() and removeLast().

T QList::value(qsizetype i) const

Returns the value at index position i in the list.

If the index i is out of bounds, the function returns a default-constructed value. If you are certain that i is within bounds, you can use at() instead, which is slightly faster.

See also at() and operator[]().

T QList::value(qsizetype i, QList<T>::parameter_type defaultValue) const

This is an overloaded function.

If the index i is out of bounds, the function returns defaultValue.

bool QList::operator!=(const QList<T> &other) const

Returns true if other is not equal to this list; otherwise returns false.

Two lists are considered equal if they contain the same values in the same order.

This function requires the value type to have an implementation of operator==().

See also operator==().

QList<T> &QList::operator+=(const QList<T> &other)

Appends the items of the other list to this list and returns a reference to this list.

See also operator+() and append().

[since 6.0] QList<T> &QList::operator+=(QList<T> &&other)

This is an overloaded function.

This function was introduced in Qt 6.0.

See also operator+() and append().

QList<T> &QList::operator+=(QList<T>::parameter_type value)

This is an overloaded function.

Appends value to the list.

See also append() and operator<<().

QList<T> &QList::operator+=(QList<T>::rvalue_ref value)

This is an overloaded function.

See also append() and operator<<().

bool QList::operator<(const QList<T> &other) const

Returns true if this list is lexically less than other; otherwise returns false.

This function requires the value type to have an implementation of operator<().

QList<T> &QList::operator<<(QList<T>::parameter_type value)

Appends value to the list and returns a reference to this list.

See also append() and operator+=().

QList<T> &QList::operator<<(const QList<T> &other)

Appends other to the list and returns a reference to the list.

[since 6.0] QList<T> &QList::operator<<(QList<T> &&other)

This is an overloaded function.

This function was introduced in Qt 6.0.

QList<T> &QList::operator<<(QList<T>::rvalue_ref value)

This is an overloaded function.

See also append() and operator+=().

bool QList::operator<=(const QList<T> &other) const

Returns true if this list is lexically less than or equal to other; otherwise returns false.

This function requires the value type to have an implementation of operator<().

[default] QList<T> &QList::operator=(QList<T> &&other)

Move-assigns other to this QList instance.

[default] QList<T> &QList::operator=(const QList<T> &other)

Assigns other to this list and returns a reference to this list.

QList<T> &QList::operator=(std::initializer_list<T> args)

Assigns the collection of values in args to this QList instance.

bool QList::operator==(const QList<T> &other) const

Returns true if other is equal to this list; otherwise returns false.

Two lists are considered equal if they contain the same values in the same order.

This function requires the value type to have an implementation of operator==().

See also operator!=().

bool QList::operator>(const QList<T> &other) const

Returns true if this list is lexically greater than other; otherwise returns false.

This function requires the value type to have an implementation of operator<().

bool QList::operator>=(const QList<T> &other) const

Returns true if this list is lexically greater than or equal to other; otherwise returns false.

This function requires the value type to have an implementation of operator<().

QList<T>::reference QList::operator[](qsizetype _i_)

Returns the item at index position i as a modifiable reference.

i must be a valid index position in the list (i.e., 0 <= i < size()).

Note that using non-const operators can cause QList to do a deep copy.

See also at() and value().

[noexcept] QList<T>::const_reference QList::operator[](qsizetype _i_) const

This is an overloaded function.

Same as at(i).