[Solved] Qt 5.1 statusbar character encoding bug
-
Hello,
I may have found a bug in the QStatusBar in Qt5.1.
My locale is French and I'm trying to display accents : "éàêùç ..." and all of them appear as black "?" if I compile with Qt5.1.
If I compile with Qt4.8.4 the accents appear.You can make the test, just create a new project application and add after "ui->setupUI(this)" :
@ui->statusbar->showMessage("éàêùç");@Can you confirm it's a regression / bug or did I miss something ?
Thanks in advance.
EDIT : forgot to say that the others texts, used in QLabels are displaed correctly.
-
Hi,
Is the exec-charset of your application is UTF-8? -
I do think so since if I build my QString with QString::fromLatin1(), the accents are displayed correctly.
What I don't understand is why do I need to specify it only for the QStatusBar ?
In other QLabels and even in QML Text they are displayed correctly. -
[quote author="eMixam" date="1374570249"]I do think so since if I build my QString with QString::fromLatin1(), the accents are displayed correctly.
[/quote]
It means that the exec charset of your application is latin1! So you need to use QLatin1String or QString::fromLatin1() to convert the string from char* to QString.[quote author="eMixam" date="1374570249"]
What I don't understand is why do I need to specify it only for the QStatusBar ?
In other QLabels and even in QML Text they are displayed correctly.[/quote]Are your sure that:
@
ui->label->setText("éàêùç");
@works in your source code?
-
[quote author="1+1=2" date="1374571527"]
It means that the exec charset of your application is latin1! So you need to use QLatin1String or QString::fromLatin1() to convert the string from char* to QString.[/quote]Okay, so QString is using UTF-8 as default hence the need to use QString::fromLatin1() ...
[quote author="1+1=2" date="1374571527"]
Are your sure that:@ui->label->setText("éàêùç");@
works in your source code?[/quote]
Nope, does not. This means that it's the Designer who does the conversion.
I still don't know how the QtQuick part of my application does the conversion of units.Thanks for your help.
EDIT : I know why the QtQuick part displays the accents : it takes its data from a XmlListModel and the XML file is encoded in UTF-8 :)