Reputation: 2184
I'm trying to use the sqlite3
library with Qt.
I have my database path stored in a QString
. Since sqlite3_open
wants a const char*
, I tried doing the following:
const QString qpath = whateverGivesIt();
const char* path = qpath.toUtf8().constData();
sqlite3_open(path, &connection);
With little success. If I use
qDebug() << qpath;
qDebug() << path;
Both of them give me the same (right) path. But SQLite3 seems not to be accepting it, since I see a new file being created: hЮUUU
. Also, the database to which I'm connected is of obviously empty, as it seems that SQLite3 is connecting to a new file.
Any ideas? Please suggest (:
Upvotes: 0
Views: 39
Reputation: 2080
Qt has its own implementation for sqlite which works in a stable way with QObjects check : http://katecpp.github.io/sqlite-with-qt/
Upvotes: 1