Accent Qt 5.0.2

  • Hello,

    I work on Microsoft Visual Studio 2010 with the last service pack and I have a problem when I draw a QTreeView.
    The item have a strange character.

    For example this is what I do:
    @QStandardItem *qsInfos = new QStandardItem("Infos");
    sTexte = "Vérificateur"
    qsInfos->appendRow(new QStandardItem(sTexte.c_str()));@

    I tried
    @qsInfos->appendRow(new QStandardItem(QString::fromStdString(sTexte)));@

    @qsInfos->appendRow(new QStandardItem(QObject::tr(sTexte.c_str()));@

    But it didn't work, I have a strange character in the QTreeView

  • I think that could be a text encoding problem. Try to put in your application:

    @QTextCodec *utf8 = QTextCodec::codecForName("UTF-8");

  • Thank you for your answer.


    I don't found this method in Qt 5.0.2.

    I tried

    @QTextCodec *utf8 = QTextCodec::codecForName("UTF-8");

    But it didn't solved my problem.

    Another idea ?

  • Sorry for setCodecForCStrings, it is deprecated in Qt 5.0.2. Could you try to do this?

    @qsInfos->appendRow(new QStandardItem(QString::fromLatin1(sTexte)));@

    Despite it I think that could be a problem with your project/files encoding.

  • Yes it's works.
    But I don't want to do this for all text.

    I tried in the constructor:

    @QTextCodec *codec = QTextCodec::codecForName("ISO 8859-1");

    But it didn't work

  • Take a look to "this forum topic": It could help you.

  • Thanks for your help, it doesn't resolve my problem.
    My project is configure for "UTF8" encodage.

    Actualy I do


    If anyone find a better solution

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.