Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1039101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:03:29+00:00 2026-05-16T15:03:29+00:00

I am creating a SQLite database from qt like this: QSqlDatabase db = QSqlDatabase::addDatabase(QSQLITE,

  • 0

I am creating a SQLite database from qt like this:

QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", mConnectionName);
db.setDatabaseName("myDattabse.DB");
if (!db.open()) {  
return false;
}

When trying to insert Macedonian characters in the SQLite database, the characters are inserted as ???.

According to this link http://www.qtcentre.org/threads/26202-SQLite-connection-and-encoding?highlight=unicode+and+sqllite , I need to create my database with utf-16 encoding to solve my problem. SQLite default encoding is utf-8. How can I do that? Where to specify this option in my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:03:30+00:00Added an answer on May 16, 2026 at 3:03 pm

    From my understanding you should be fine with UTF8, pls, check if an example below would work for you:

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(":memory:");
    
    if( !db.open() )
    {
        qDebug() << db.lastError();
        qFatal( "Failed to connect." );
    }
    
    QSqlQuery query;
    
    query.prepare("CREATE TABLE IF NOT EXISTS names (id INTEGER UNIQUE PRIMARY KEY, test_field VARCHAR(30))");
    query.exec();
    
    query.prepare(QObject::trUtf8("INSERT INTO names (id, test_field) VALUES (1, 'тест1')"));
    query.exec();
    query.prepare(QObject::trUtf8("INSERT INTO names (id, test_field) VALUES (2, 'тест2')"));
    query.exec();
    
    QSqlQuery select("SELECT test_field FROM names");
    while (select.next())
    {
        qDebug() << select.value(0).toString();
    }
    

    output should be:

    "тест1" 
    "тест2" 
    

    now back to your original question, I believe you can have you sqlite database in UTF-16 as default encoding if the database is opened with sqlite3_open16 function. According to QT source code (qsql_sqlite.cpp QSQLiteDriver) they are using sqlite3_open_v2 function to open the connection to database which is UTF-8, but again, there is nothing wrong with it for working correctly with Cyrillic characters.

    hope this helps, regards

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a database like this : SQLiteDatabase db = openOrCreateDatabase(mydata.db,SQLiteDatabase.CREATE_IF_NECESSARY,null); try {
I have creating a login form where I have created sqlite database,in this I
I am creating a SQLite database. To get data from the table I am
I am creating a web application that is accessing a SQLite database in the
I am creating a system that will store objects in an SQLite Database. I
I'm creating a dictionary app. My Sqlite database is about 15MB and on the
When creating my SQLite database in Android I set the database locale - db.setLocale(new
I am creating application which stores the users financial information in a sqlite database.
I'm creating an application to input input string values from EditText into a SQLite
i am creating an app that needs a database. i created it using sqlite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.