0

I'm not able to display accents of the database.

Example:
Database: Grégoire,
php: Grégoire,
Qt: Grégoire

How can I modify Qt output to get this "é", or event better "e", again?

My database is in UTF8-unicode-ci

This is my Qt code:

query.prepare("SELECT FIRSTNAME FROM USERS WHERE ID= :nid");
query.bindValue(":nid", id);
query.exec();

if (query.next())
{
QString str = query.value(0).toString();
}
gr3g
  • 2,866
  • 5
  • 28
  • 52
  • 1
    Possible duplicate http://stackoverflow.com/questions/8705488/set-qt-default-encoding-to-utf-8 – slapyo Oct 14 '14 at 17:58
  • See also http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – Funk Forty Niner Oct 14 '14 at 18:06
  • What database is that? Did you tell Qt to use UTF8 to encode and decode strings coming from that database? Usually it's a database option you can pass. Otherwise, you need to do manual conversions. – peppe Oct 14 '14 at 19:23

1 Answers1

0

Try:

QString str = query.value(0).toString().toLatin1();

You will get Grégoire

Jablonski
  • 18,083
  • 2
  • 46
  • 47