Welcome!
I would like to ask if it is possible to create QList of QLists?
I've tried to do something like this:
Qt Code:
QList<QList<int> > myList;To copy to clipboard, switch view to plain text mode
but it doesn't compile.
Please help!
Welcome!
I would like to ask if it is possible to create QList of QLists?
I've tried to do something like this:
Qt Code:
QList<QList<int> > myList;To copy to clipboard, switch view to plain text mode
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
__________________________________________________
My projects: calculator MathGraphica ; SuperEpicMegaHero game ; GooglePlay ; bitbucket ; github
Like my projects ? Buy me a kofi
Can you show what compilation error you are getting ?
Try this
Qt Code:
QList<int> myIntList; QList<myIntList> listOFIntList;To copy to clipboard, switch view to plain text mode
Last edited by wysota; 23rd January 2010 at 14:52.
QList<QList<int> > myList;
This works fine, the problem should be somewhere else. Have you added the include?
Qt Code:
typedef QList<YourType> TypeList; // Type definition ... QList<TypeList> list; // Variable definition.To copy to clipboard, switch view to plain text mode
Or, you could try this way (notice the spaces):Qt Code:
QList< QList<YourType> > list;To copy to clipboard, switch view to plain text mode
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.I do believe, however, that with C++11 this is parsed correctly
Or
to your project configuration file (in Qt5).
Bookmarks