copying a std::vector to a qvector

Look at:

std::vector<T> QVector::toStdVector () const

QVector<T> QVector::fromStdVector ( const std::vector<T> & vector ) [static]

From docs


If you are creating a new QVector with the contents of a std::vector you can use the following code as an example:

   std::vector<T> stdVec;
   QVector<T> qVec = QVector<T>::fromStdVector(stdVec);

'fromStdVector' has been explicitly marked deprecated recently. Use following code:

std::vector<...> stdVec;

// ...       

QVector<...> qVec = QVector<...>(stdVec.begin(), stdVec.end());

Tags:

C++

Qt