[Qt-interest] Defining large QMap

Malyushytsky, Alex alex at wai.com
Tue Nov 2 20:56:40 CET 2010


You can save it in any format you want and add this file to resources, then read from it the same way you read  icons.
It is handled by QFile automatically, you can refer to the resource paths instead of ordinary file system paths.

P.S. Personally I would not recommend such approach for storing static data cause it requires additional application to write such binary file and this application still need to get this data somewhere.

Regards,
   Alex



From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of yogesh upreti
Sent: Tuesday, November 02, 2010 12:28 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Defining large QMap

Hello Andre,
Thanks for reply. I am using a similier approach, but I don't want to give that ASCII file to user of software. Is there a way to have it as a Binary file?
How is the method you say about using resourse file? I use that for images and icons but never for Maps.

Thanks
Yogesh Upreti

Message: 4
Date: Mon, 01 Nov 2010 07:37:09 +0100
From: Andre Somers <andre at familiesomers.nl>
Subject: Re: [Qt-interest] Defining large QMap
To: qt-interest at trolltech.com
Message-ID: <4CCE6015.9000900 at familiesomers.nl>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

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?



---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.

“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”

“Please consider our environment before printing this email.”




More information about the Qt-interest-old mailing list