#include#include int main() { QVector v; v.append(1); v.append(2); v.append(3); qDebug() << v; // Output: (1, 2, 3) return 0; }
#include#include int main() { QVector v{"apple", "banana", "cherry"}; qDebug() << v[0]; // Output: "apple" qDebug() << v[1]; // Output: "banana" qDebug() << v[2]; // Output: "cherry" return 0; }
#includeThese examples show how to use QVector to create, modify, and access dynamic arrays in C++. The package library for QVector is the Qt libraries.#include int main() { QVector v{1, 2, 3, 4, 5}; v.remove(2); qDebug() << v; // Output: (1, 2, 4, 5) v.removeOne(2); qDebug() << v; // Output: (1, 4, 5) return 0; }