I'm trying to create a Qvector from and std::Vector.
I can of course copy it element by element using a for loop, but I'm looking for a better way to do it.
So I tried:
QVector<double> qv = QVector<double>::fromStdVector(values) ;
This works fine but I get a warning that it's deprecated.
I followed Hadi Navapour's suggestion from copying a std::vector to a qvector
and tried the following:
QVector<double> qv = QVector<double>(values.begin(), values.end());
but this code with begin() and end() does not compile, I get the following error:
error: no matching function for call to ‘QVector::QVector(std::vector::iterator, std::vector::iterator)’ QVector qv = QVector(values.begin(), values.end());
I believe this is supposed to use the following constructor QVector(InputIterator first, InputIterator last)
I can't get it to work.
Could someone please explain the right non-deprecated way to copy an std::vector to a Qvector?
Thanks in advance!