I'm currently working on a project in C++ and I'm using Visual Studio 2010 Express along with Qt Creator 5.3.2. for the GUI of the application.
My problem is that I want to convert a 2D vector to a 2D QVector and I don't really know how to do this. I have used, for example, the fromStdVector() for the conversion of a 1D vector to a 1D QVector, but I cannot successfully transfer the data from a 2D vector to a 2D QVector (with this function). If anyone could help, I would much appreciate it.
Source Code:
QVector< QVector<double> > test2D; // 2D QVector
vector < vector<double> > std_test2D; // 2D vector
test2D.resize(20); // dimensions of the 2D QVector
for(int i=0; i<20; ++i)
{
test2D[i].resize(44);
}
std_test2D.resize(20); // dimensions of the 2D vector
for(int i=0; i<20; ++i)
{
std_test2D[i].resize(44);
}
for(int i=0; i<20; i++) // convert vector to QVector???
{
test2D[i].fromStdVector(std_test2D[i]);
}
You're not assigning the value. I think this should work using the example code from the documentation: