QListmyList = {1,2,3,4}; int lastItem = myList.takeLast(); // remove and return 4
QListIn this example, we create a QList of QStrings and initialize it with values. We then use the takeLast function to remove the last string ("orange") and store it in a variable. The QList class is part of the Qt Core library.myStrings = {"apple", "banana", "orange"}; QString lastString = myStrings.takeLast(); // remove and return "orange"