Problem in coding Strings Qt

4

I'm having a problem encoding strings in Qt . When I show something in a QMessageBox or give drawText to paintEvent , my strings are badly formatted, as if they were not in the correct encoding.

Here's how it appears:

LineChart Code:

if(bTitle){
    p.setPen(titleColor);
    p.drawText((width()/2 - (getTitle().size() * 5)),40, getTitle());
}

where getTitle is:

QString LineChart::getTitle(){
    return this->Title;
}

Usage Debian 7.1 64 bits.

Does anyone know how to solve?

    
asked by anonymous 15.06.2014 / 04:17

1 answer

4

Change your setTitle from:

void LineChart::setTitle(QString Title){
    this->Title = Title;
}

To:

void LineChart::setTitle(const char * Title){
    this->Title = QString::fromUtf8(Title);
}

and add a trUtf8 in the QMessageBox, like this:

QMessageBox::information(this, trUtf8("Joaçaba"));

    
15.06.2014 / 05:11