Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 5 and accented characters

Qt 5 and accented characters

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    puffosauro
    wrote on last edited by
    #1

    Hi.

    I'm porting my aplication from Qt 4.7.3 to Qt 5.2.0 and I have this problem: the accented characters (eg é à ò) are sometimes drawn with a "question mark symbol".
    This appens when the text is taken directly from the source code, eg

    @
    painter->drawText(0, 0, "Città");
    painter->drawText(0, 0, QString("Città"));
    @

    or also with
    @
    tr("Città")
    @

    if the sentence is let untraslated. In this case also in Qt Linguist I see the "question mark symbol" instead of the accented character. Instead if the text is translated (with accented characters in the translation) they are drawn correcly. Also if I draw a text from a variable that takes the text eg from user input, it works.

    It seems that these characters are not recognized properly from source code.

    With Qt 4 all worked perfecly.

    I have built Qt 5 from git using Visual Studio 2008, without ICU. I read that ICU is used for unicode support, but I don't know if it is needed in this case.

    I build my application with Visual Studio 2008, using the old Visual Studio project that worked with Qt 4.

    Thank you for help.

    1 Reply Last reply
    0
    • frederikF Offline
      frederikF Offline
      frederik
      wrote on last edited by
      #2

      Check out the documentation for QString::fromLocal8Bit and fromUtf8, you need to have the right encoding and it's never a good idea to initialize QString directly from char arrays.
      Make sure to know which encoding the files are saved in.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        puffosauro
        wrote on last edited by
        #3

        QString::fromLocal8Bit works, thanks!

        There is only a problem: if I use QObject::tr() I have to pass a char array, written directly in the source code....

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved