[solved] QSqlDatabase QSQLITE pointer?
how do I get a pointer out of QSqlDatabase with type QSQLITE?
@ QSqlDatabase database = QSqlDatabase::addDatabase("QSQLITE");
Calling addDatabase on the pointer does not really work:
@ QSqlDatabase *databaseP = new QSqlDatabase;
bq. "Driver not loaded Driver not loaded"
As ever, short after posting, I found the solution:
@ QSqlDatabase *databaseP = new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE"));
Why do you need that pointer ? It's not the standard use of QSqlDatabase. Once you create the connection (which will be the default), all further calls to e.g. QSqlQuery will use the default connection
[quote author="SGaist" date="1388433230"]Hi,
Why do you need that pointer ? It's not the standard use of QSqlDatabase. Once you create the connection (which will be the default), all further calls to e.g. QSqlQuery will use the default connection[/quote]
Hi. You are right, I just did not know that until I prepared my first SQL-statement.
A bit OT but is there Qt SQLite support for iOS? On Mac I can open my database (db->open();) but on iOS I get:
@QSqlDatabase: QSQLITE driver not loaded
QSqlDatabase: available drivers: @
Do I need an Qt-Plugin like AVMedia needs?
Qt for iOS is a static build so you need to tell Qt which plugin you will be using. Look for Q_IMPORT_PLUGIN and the related documents in Qt's documentation.
Also, beware that you cannot create files everywhere on iOS you only have access to some predefined folder, use QStandardPaths to retrieve these.
Thanks, I will look into this!
I didn't know about QStandardPaths & Q_IMPORT_PLUGIN - very very useful. It all works now! Thank you!
You're welcome !
Now that you have it working, don't forget to update the thread title prepending [solved] so other forum users may know a solution has been found :)
Would you be so kind and have a quick look at my post at the bottom under "Qt 5.1 ios How to Bundle and use SQLite database in application":http://qt-project.org/forums/viewthread/34102 ?
I have the same problem but do not get it to work.
Would be great!
Thanks and cheers