#include#include int main() { QVector myVector; if (myVector.isEmpty()) { qDebug() << "Vector is empty"; } else { qDebug() << "Vector is not empty"; } return 0; }
#includeIn this example, a QVector of strings is declared and initialized with three elements. The isEmpty function is called on the vector and because it has elements, the output will be "Vector is not empty". Package library: Qt C++ library.#include int main() { QVector myVector = {"apple", "banana", "cherry"}; if (myVector.isEmpty()) { qDebug() << "Vector is empty"; } else { qDebug() << "Vector is not empty"; } return 0; }