Why am I not able to create a QList of QList's?
Ex:
Code:
QList<QList> * tileList; Error: type/value mismatch at argument 1 in template parameter list for 'template<class T> class QList' expected a type, got 'QList'
Printable View
Why am I not able to create a QList of QList's?
Ex:
Code:
QList<QList> * tileList; Error: type/value mismatch at argument 1 in template parameter list for 'template<class T> class QList' expected a type, got 'QList'
Every QList requires a type, so also the second one.
What do you mean by that?Quote:
Every QList requires a type, so also the second one.
He meant something like this:
QList<QList<some_type> > list; // notice the space within '>' and '>'
Ok, but how can I add a QList?
Ex:
Code:
QList< QList<int> > * tileList; QList<int> list; tileList << list;
Gives an error:
Code:
error: no match for 'operator<<' in '((Widget*)this)->Widget::tileList << rowList' note: candidates are: QDataStream& operator<<(QDataStream&, const QChar&) //Huge list follows.....
Edit: If I use:
The application crashes with "Invalid parameter passed to C runtime function.Code:
tileList->append(rowList);
Invalid parameter passed to C runtime function."
That's because your list of lists is actually a pointer to a list of lists - a pointer which you never allocate or initialize. Lose the '*'.
Or use something like:
if you really need it on the heap.Code:
QList<QList<int> > *list = new QList<QList<int> >;
And read a little about pointers, if you have int *p; you can't legally use p because it points to an unspecified location.
You need an object and a pointer, something like:
int number = 10; int *p = &number;
or use the pointer to create an object on the heap (that object doesn't have a name, but it is there):
int *p = new int(10);
You are right. I forgot. Thanks for the lesson. :)