Tuesday, November 17, 2009

Beware of QDomElement::setAttribute with floats and doubles

QDomElement::setAttribute with floats and doubles formats the numbers according to the current locale as specified by the documentation and this is for sure going to bite you. It did for us in Okular where people lost annotations when moving from one computer to another since the user was using a , locale in one of them and a . locale in other.

So if you use QDomElement::setAttribute with floats and doubles just add QString::number to the second parameter or as Thiago suggested switch to QXmlStreamWriter

No comments: