#include#include #include int main() { QVector fruits; fruits.push_back("Apple"); fruits.push_back("Banana"); fruits.push_back("Orange"); std::cout << "Number of fruits in the vector: " << fruits.size() << std::endl; return 0; }
#includeIn this example, we create a QVector of type int and add three numbers to it using the push_back() function. We then remove the last element of the QVector using the pop_back() function. Finally, the size of the QVector is printed. Package Library: Qt Library#include int main() { QVector numbers; numbers.push_back(10); numbers.push_back(20); numbers.push_back(30); numbers.pop_back(); std::cout << "Number of elements in the vector: " << numbers.size() << std::endl; return 0; }