#include#include int main() { QVector vec = { 10, 20, 30, 40, 50 }; vec.pop_back(); for (const auto& i : vec) { qDebug() << i << " "; } return 0; }
#includeIn this example, we have created a QVector of QString type and initialized it with values. Then we have used the pop_back() function to remove the last element of the vector. Finally, we have printed the elements of the modified vector to verify that the last element is removed. Package library: Qt library.#include #include int main() { QVector vec = { "Hello", "World", "Welcome", "to", "Cpp" }; vec.pop_back(); for (const auto& i : vec) { qDebug() << i << " "; } return 0; }