Q:

Problems with accents in using c++ and qt

I'm writing a program in spanish. I want to tell the user that a file has been loaded. In spanish that is:
ui->teLog->append("Se cargó el archivo: " + filename);

However the spanish parts gets outputted as:

Se cargÃ³ el archivo:

I know the problem is the encoding (like I need to tell the program this is UTF8, I think).
Is there anyway to do this?

A:

The normal QString constructor assumes you're writing ASCII characters. If you use QString::fromUtf8() in this case it should work:
ui->teLog->append(QString::fromUtf8("Se cargó el archivo: ") + filename);

Also:
QTextCodec::setCodecForCStrings( QTextCodec::codecForName("utf8") );

(See this answer for more info)

