2012-12-10 126 views
0

我想将float**参数的列表传递给仅与C-syle和float**一起工作的一些方法(但我们认为我们可以使用QList<>作为参数类型)。Qt C++ - QList <float**>类型不允许

我试着用

QList< float** > list_ = new QList< float** >(); 

,但是这是行不通的。我应该用什么来代替?替代Qt容器的二维矩阵列表是什么?

感谢

+1

这是为什么“不工作“?你有错误吗?哪一个? – alestanis

+1

这是因为你正在使用'new'运算符,它将在堆上分配它并返回一个指针。等号后不需要做任何事情。 –

回答

9

您使用的是像语法(或C#或其他)

在C一个java ++中,它应该是

QList<float**> *list_ = new QList<float**>() ; //Pointer to a heap allocated list, Closer to what you wanted to do i think. NEED TO CALL "delete list_" once you are done with it. 

QList<float**> list_; //List on the stack, more c++ish, destroyed once it goes out of scope. 
+0

由于隐式共享,在堆上创建Qt容器几乎总是荒谬的。 –