Code in the operation of the database will appear garbled, the solution
QTEXTCODEC::SETCODECFORTR (Qtextcodec::codecforname ("GBK")); Insert Data statement if the Chinese must first qobject::tr (), that is, to encode,
such as Query.exec ("INSERT into Student" (Schnum, Name, Sex, Nation) VALUES (2614103, ' tianmen, ' male ', ' Han ') '); Change to Query.exec (Qobject::tr ( "INSERT into student (schnum, name, Sex, Nation) VALUES (2614103, ' tianmen, ' male ', ' Han ')");
The results will be displayed correctly in the display. Second, the place above the code is changed to: Qtextcodec::setcodecfortr (Qtextcodec::codecforlocale ())), set to local encoding, insert data when the query statement is QOBJECT::TR (), The results of the database and display are Chinese, can be displayed correctly. Reference http://www.qtcn.org/bbs/read.php?tid=18870
Sqlite3 Chinese garbled problem Qt4