我目前工作的一个项目在C++中,我使用Visual Studio 2010速成与Qt Creator的5.3.2一起。为应用程序的GUI。将2D矢量2D QVector C++
我的问题是,我想一个二维矢量转换成2D QVector,我真的不知道如何做到这一点。我已经使用,例如,fromStdVector()为一维向量,以一维QVector的转化,但我不能成功地从2D矢量的数据传送到一个2D QVector(使用此功能)。如果有人可以帮忙,我会非常感激。
源代码:
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]);
}