Qt 5 and accented characters
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
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.
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.
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....