[Qt-interest] Storing Qt properties to file

Schimkowitsch Robert Robert.Schimkowitsch at andritz.com
Mon Sep 26 12:53:12 CEST 2011


My only locale-dependent types I am aware of right now is float and
double.
The way I read the QString documentation, I should be fine using
QString::number
and
QString::toString

because QString::number:
"Unlike QLocale::toString(), this function does not honor the user's
locale settings."
...which hopefully means the numbers always are formatted with ".",
never ","

and QString::toString:
"If the string cannot be interpreted according to the current locale,
this function falls back on the "C" locale."
...which is what should happen to the string I got using "toString".

Does that sound right, or am I digging my own hole already?

Kind regards

Robert Schimkowitsch


-----Original Message-----
From: qt-interest-bounces+robert.schimkowitsch=andritz.com at qt.nokia.com
[mailto:qt-interest-bounces+robert.schimkowitsch=andritz.com at qt.nokia.co
m] On Behalf Of Bo Thorsen
Sent: Monday, September 26, 2011 12:44 PM
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Storing Qt properties to file

Hi Robert,

If you write to a .ini file, you can use QSettings and don't have to 
worry about any of this. It just works.

But if you prefer XML or some other file type, you have a bit more work 
to do.

First step is to make sure you don't have locale dependent values 
written. Like numbers are written 1.000,00 in Danish but 1,000.00 in 
English. So you should use something like this:

http://www.fioniasoftware.dk/blog/?p=21

For strings, you should just use UTF-8 as the encoding, then you don't 
have to worry about it.

I hope this helps.

Bo Thorsen.

Den 26-09-2011 11:23, Schimkowitsch Robert skrev:
> Hi,
>
> I want to be able to write the properties of my object to file in a
> locale-independent way, and be able to restore the object using that
> stored information later on.
>
> Before I start reinventing the wheel, I'd like to know whether
something
> like this already exists (I couldn't find it, but then again Qt has
> grown big).
>
> My plan includes the following steps. If you happen to know existing
> classes or samples that cover those steps, please let me know!
>
> 1) Read and write QVariant: Handling of basic data types (float is a
bit
> tricky, unicode strings might be)
> 2) Write a reader and writer that writes all Q_PROPERTIES of an object
> to an XML file, and reads them again, restoring the object properties.
> By using propertyOffset() of QMetaObject, I should be able to filter
out
> base class properties that should not be saved and restored.
>
> 3) Define the needed properties in my objects, and call the
reader/writer
>
> Kind regards
>
> *Robert Schimkowitsch*
>
>
------------------------------------------------------------------------
>
> This message and any attachments are solely for the use of the
intended
> recipients. They may contain privileged and/or confidential
information
> or other information protected from disclosure. If you are not an
> intended recipient, you are hereby notified that you received this
email
> in error and that any review, dissemination, distribution or copying
of
> this email and any attachment is strictly prohibited. If you have
> received this email in error, please contact the sender and delete the
> message and any attachment from your system.
>
> ANDRITZ HYDRO GmbH
> Rechtsform/ Legal form: Gesellschaft mit beschrankter Haftung /
Corporation
> Firmensitz/ Registered seat: Wien
> Firmenbuchgericht/ Court of registry: Handelsgericht Wien
> Firmenbuchnummer/ Company registration: FN 61833 g
> DVR: 0605077
> UID-Nr.: ATU14756806
>
> Thank You.
>
>
------------------------------------------------------------------------
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest


Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest

#####################################################################################
This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.
Thank You.
  ANDRITZ HYDRO GmbH
  Rechtsform/ Legal form: Gesellschaft mit beschrankter Haftung / Corporation 
  Firmensitz/ Registered seat: Wien 
  Firmenbuchgericht/ Court of registry: Handelsgericht Wien 
  Firmenbuchnummer/ Company registration: FN 61833 g
  DVR: 0605077 
  UID-Nr.: ATU14756806
#####################################################################################




More information about the Qt-interest-old mailing list