Accentuation problems



  • I'm trying to show some messages and texts on UI, but the messages appears with encoding errors. I try some stuff to fix it but nothing works.
    What should I do?
    I example code:

    @
    CaixaDialogo::getMensagemAviso("Modelo de Veículo não encontrado.")->show();
    @

    @
    QMessageBox* CaixaDialogo::getMensagemAviso(QString mensagem)
    {
    qDebug() << "Passou aqui!";
    QMessageBox* msgBox = new QMessageBox();
    msgBox->setText( mensagem );
    return msgBox;
    }
    @

    I try to use the QString::fromUtf8() and doesn't works.



  • Maybe:

    @
    CaixaDialogo::getMensagemAviso(QString("Modelo de Veículo não encontrado."))->show();
    @

    QString is unicode aware.



  • The problem persists...



  • This is probably an encoding problem in your file.

    Try in QtCreator tools/options, then behavior in Text Editor
    select default encoding UTF-8.

    Then with some tools like notepad++, encode your file in utf8.
    The problem will be hopefully solved.



  • This?:

    @
    CaixaDialogo::getMensagemAviso(QString("Modelo de Veículo não encontrado.").toUtf8())->show();
    @



  • I'm using the Default, system etc...
    Appears to be UTF-8....

    I will try... I will need to use the "convmv".
    Every single file of my project will need to be converted? Could I change the setting, opening the files and saving then again and the QtCreator will change to UTF-8?!



  • broadpeak, to toUtf8 change the errors only... still having problems with encoding...



  • dmcr, the file is already in UTF-8, see:

    @
    file -bi widgetms.cpp
    text/x-c; charset=utf-8
    @



  • This works... But I don't like... I need something easier and more "beautiful" to solve the problem:

    @
    CaixaDialogo::getMensagemAviso( QString::fromUtf8("Modelo de Veículo não encontrado.") )->show();
    @



  • This looks like a localisable string, so you should probably use tr() and linguist.
    See http://qt-project.org/doc/qt-4.8/linguist-manual.html


Log in to reply
 

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