Sqlite3 Chinese garbled problem Qt4

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.