QVectornumbers = {1, 2, 3, 4, 5}; int value = 3; if (numbers.contains(value)) { qDebug() << "The QVector contains the value " << value; } else { qDebug() << "The QVector does not contain the value " << value; }
QVectorIn both examples, the contains method is used to check if the given value is present in the QVector. If the value is present, the program prints a message indicating that the QVector contains the value. If the value is not present, the program prints a message indicating that the QVector does not contain the value. This functionality is part of the Qt library, which is a cross-platform application development framework. The QVector class is part of the QtCore package in the Qt library.names = {"Alice", "Bob", "Charlie"}; QString value = "Bob"; if (names.contains(value)) { qDebug() << "The QVector contains the value " << value; } else { qDebug() << "The QVector does not contain the value " << value; }