×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    58

    QLocale::toString(double) not displaying thousands-separator on X7 Symbian Anna

    Hi, I'm running into a problem displaying currency values on a Nokia X7 running Symbian Anna. The thousands separator symbol, a comma here in the U.S., a period in Europe, isn't appearing in the string output of QLocale().toString(). It seems to be inserting something like a null or a 127 character instead. This problem doesn't exist with the same code on an N8 running Symbian Anna or ^3. Why should the X7 exhibit this problem? Is there a fix for this?

    Looking forward to an answer,

    Phil
    Last edited by pgarofalo; 2011-11-11 at 21:39.

  2. #2
    Registered User
    Join Date
    May 2009
    Posts
    58

    Re: QLocale::toString(double) not displaying thousands-separator on X7 Symbian Anna

    Here's a follow-up and the solution.

    On the X7 running Symbian ^3 Anna, QLocal::toString(double) works as expected for Italian, German, Spanish, and Portuguese. That is, a period is used as the thousands separator and a comma for the decimal fraction separator. For French and English, it uses a space to separate thousands and a period as the decimal mark.

    Using a (thin) space to separate thousands is, according to Wikipedia, recommended by international standards bodies. So the X7 is pushing the envelope on this point (sorry about the pun). That's great, but unfortunately it can expose a problem if you're using void QPainter::drawText ( const QRectF & rectangle, const QString & text, const QTextOption & option = QTextOption() ) without specifying the option parameter. If you call drawText with a rectangle returned from QFontMetrics::boundingRect(QString) and use the default QTextOption, which has word wrap on, the last "word" will not appear. It will be wrapped below the bottom of the bounding rectangle. This is what was happening in my app. I wasn't seeing this on other phones, because they're using the comma for the thousands separator. Solutions include the following: 1) use a rectangle wider than the one returned from boundingRect, 2) pass in a QTextOption with word wrap turned off, or 3) use QStaticText instead of QString and drawText.

    Hope this helps others.

    Phil
    Last edited by pgarofalo; 2011-11-16 at 03:03.

Similar Threads

  1. Why called Symbian Anna, Symbian Belle?
    By patrickz in forum Symbian
    Replies: 7
    Last Post: 2011-08-25, 11:03
  2. Replies: 0
    Last Post: 2011-04-14, 08:59
  3. Replies: 0
    Last Post: 2010-12-23, 12:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •