[Qt-interest] Defining large QMap
Andre Somers
andre at familiesomers.nl
Mon Nov 1 07:37:09 CET 2010
Op 31-10-2010 23:50, yogesh upreti schreef:
> Hello Group,
> I need a bit help. What is a good method of defining a big Map.
> I have around 150 key pair value. Do I have to declare the map and
> define each element one by one or there is a elegant way of doing this??
>
Basically, yes, you have to do it one by one. However, you don't need to
put a huge hardcoded list of QMap::insert statements in your code, of
course. I usually use a file with the data, either compiled in as a
resource or externally, and load that in. You could even use a
QDataStream to load the whole map in one go, but that means making sure
that your input data is in the right format.
André
More information about the Qt-interest-old
mailing list