QList removeAt is a member function of the Qt C++ library, which removes the element at the specified index position from the list. It returns a modified QList with the element removed. If the index is out of range, it does nothing.
Example 1: Removing an element from a list
QList numbers = {1, 2, 3, 4, 5}; numbers.removeAt(2); // removes element at index 2 which is '3' // now the list becomes {1, 2, 4, 5}
Example 2: Removing multiple elements from a list using a loop
QList names = {"John", "Mary", "Alice", "Bob", "Carol"}; for (int i = 0; i < names.count(); i++) { if (names[i].startsWith("A")) { names.removeAt(i); // removes elements that start with 'A' i--; // update index after removal } } // now the list becomes {"John", "Bob", "Carol"}
The package library for QList removeAt function is Qt, which is a popular cross-platform application development framework.
C++ (Cpp) QList::removeAt - 30 examples found. These are the top rated real world C++ (Cpp) examples of QList::removeAt extracted from open source projects. You can rate examples to help us improve the quality of examples.