Welcome!
I would like to ask if it is possible to create QList of QLists?
I've tried to do something like this:
Code:
QList<QList<int> > myList;
but it doesn't compile.
Please help!
Printable View
Welcome!
I would like to ask if it is possible to create QList of QLists?
I've tried to do something like this:
Code:
QList<QList<int> > myList;
but it doesn't compile.
Please help!
I did something like that with some workaround. Just define a class, in that class define a qlist, and then define a qlist of that class. Works like charm
Can you show what compilation error you are getting ?
Try this
Code:
QList<int> myIntList; QList<myIntList> listOFIntList;
QList<QList<int> > myList;
This works fine, the problem should be somewhere else. Have you added the include?
Code:
typedef QList<YourType> TypeList; // Type definition ... QList<TypeList> list; // Variable definition.
Or, you could try this way (notice the spaces):Code:
QList< QList<YourType> > list;
The first blank space is not needed, with the second is enough.
the second blank is important - if there is two consecutive '>', it is parsed as '>>', which is an operator
Hi!
Thanks for your replies. I don't know where the problem was but now everything works. I'm using that version:
QList<QList<int> > myList;
It seems only to work if there is a space between brackets.
This works:
QList<QList<int> > myList;
QList< QList<int> > myList;
This doesn't work:
QList<QList<int>> myList;
mirelon already explained this. you need a space between the two > characters, otherwise the >> is seen as operator>>().
I do believe, however, that with C++11 this is parsed correctly :)
Cheers,
_
Exactly. For example, in gcc (4.7.x and above) you can add "-std=c++11" switch to enable it.Quote:
I do believe, however, that with C++11 this is parsed correctly