#include#include int main() { QList list; list << "apple" << "banana" << "cherry"; QString removed = list.takeAt(1); qDebug() << "Removed item:" << removed; qDebug() << "List after removal:" << list; return 0; }
#includeIn this example, an invalid index (3) is passed to takeAt(). Since the list only has three items, this results in an error at runtime. The output will show that the program has crashed. The $\texttt{QList}$ class is part of the Qt Core library.#include int main() { QList list; list << 10 << 20 << 30; int invalidIndex = 3; int removed = list.takeAt(invalidIndex); qDebug() << "Removed item:" << removed; qDebug() << "List after removal:" << list; return 0; }