QListnumbers; if(numbers.empty()) { qDebug() << "List is empty"; }
QListIn this example, a QList is created with some initial elements. The clear() function is called to remove all elements from the list. The empty() function is then called to check if the list is empty. The output will be "List is empty". Package/library: Qtfruits {"Apple", "Orange", "Banana"}; fruits.clear(); if(fruits.empty()) { qDebug() << "List is empty"; }