#include#include int main() { QVector myVector = {1, 2, 3, 4, 5}; for(auto i = myVector.begin(); i != myVector.end(); ++i) { qDebug() << *i; } return 0; }
#includeIn this example, we create a QVector called myVector with five integer elements. We then use the begin() function to return a pointer to the first element of the vector. We store this pointer in an integer pointer variable named ptr. We can then access the value of the first element of the vector by dereferencing the pointer. The QVector class is part of the Qt Core library.#include int main() { QVector myVector = {1, 2, 3, 4, 5}; int* ptr = myVector.begin(); std::cout << *ptr << std::endl; // Output: 1 return 0; }