but how do I initialise the list to some size....
let me repeat my question more specifically...
Say I have the following class -
class MyClass
{
QList<QList<int> > 2dArray;
public :
MyClass()
{
// read row col from file....
// set size of Qlist to row and col
}
friend somefunction();
};
somefunction()
{
MyClass objMyClass;
for(i=0;i<row;i++)
for(j=0;j<col;j++)
objMyClass.2darray[i][j] = ;// assign some value
}
class MyClass
{
QList<QList<int> > 2dArray;
public :
MyClass()
{
// read row col from file....
// set size of Qlist to row and col
}
friend somefunction();
};
somefunction()
{
MyClass objMyClass;
for(i=0;i<row;i++)
for(j=0;j<col;j++)
objMyClass.2darray[i][j] = ;// assign some value
}
To copy to clipboard, switch view to plain text mode
here in the myclass i need to know the size of the array in the ctor and allocate the size to the list. so that later when i call any elemnt of the list, i can use it properly... QList gives error if i try to access index out of bounds...
i know i can use pointers for the problem... but just trying with QList or QVector...
Bookmarks