QT 的动态二维数组创建方法
1用指针
记得要delete,不然容易出现一堆野指针的bug;
int **a;
int row = 2;//行数
int col = 3;//列数
a = new int*[row]
for(int i = 0 ;i < row ;i++)
{
a[i] = new int[col]
}
2用QVector容器
int row = 2;
int col = 3;
QVector<QVector<int>> qv1(row);
for(int i = 2;i < row;i++)
{
qu1[i].resize(col);
}
//如果在头文件中声明行数不确定
QVector<QVector<int>> qv2;
qv2.resize(row);