SOLVED Qt 5.1 ios How to Bundle and use SQLite database in application
-
"A very short but complete mini project .pro file & main.cpp would help.
I mean an example, which runs at your computer. I would launch qmake only to get the .xcodeproject directory to test that."I just start to use QT 5.2 (with iOS even more) a mini exemple project with all files would be great
-
Hi!
Take the example in the current thread.
The important things to consider are:
.pro file:
@
QT += sql
ios:QTPLUGIN += qsqlitedeploy the database file via something like:
databases.files = ../../src/data/xp-apt.sqlite
ios: databases.path = Documents
macx: databases.path = Contents/Resources
QMAKE_BUNDLE_DATA += databasesnote, that the path databases.files is relative to the cwd, in which
the process qmake runs
@
The class implementing the initialisation/ access to the db needs to do the following for instance:
@
#include <QtSql>
(...)QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "some_name");
QSqlDatabase db = QSqlDatabase::database("some_name", false);
QString dbFilePath = "(...)";
db.setDatabaseName(dbFilePath);
db.open();
QSqlQuery *q = new QSqlQuery(db);
(...)
@Hope that helps!
-
Hi!
I'm follow this example.
But It doesn't work for me.In Desktop, iOS simulator mode is fine.
But it doesn't work with my iPad.Thanks you if you can help me.
-
I currently work on my work environment and do also have no iPad (iPhone only) but it shall work as described in above posts.
-
Hi, Jamil
Thanks for your feedback.
Then I tried with my iPhone5s. And It just work, but my iPadRetina don't.
Post QT creator error log above:This plugin does not support propagateSizeHints()
&
Failed to make complete framebuffer object 8cddThanks again for your help.
-
[Solved]
Update to QT5.2.1, iPad just work fine.Thanks you.
-
Hi,
Please help. I build my app for iPad, and using database Sqlite.
Can you explain the QString dbFilePath = "(...)"; why it is "(...)"
Thanks and regards[quote author="Jamil Raichouni" date="1389206294"]Hi!
Take the example in the current thread.
The important things to consider are:
.pro file:
@
QT += sql
ios:QTPLUGIN += qsqlitedeploy the database file via something like:
databases.files = ../../src/data/xp-apt.sqlite
ios: databases.path = Documents
macx: databases.path = Contents/Resources
QMAKE_BUNDLE_DATA += databasesnote, that the path databases.files is relative to the cwd, in which
the process qmake runs
@
The class implementing the initialisation/ access to the db needs to do the following for instance:
@
#include <QtSql>
(...)QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "some_name");
QSqlDatabase db = QSqlDatabase::database("some_name", false);
QString dbFilePath = "(...)";
db.setDatabaseName(dbFilePath);
db.open();
QSqlQuery *q = new QSqlQuery(db);
(...)
@Hope that helps![/quote]
-
It's a placeholder text that you must replace with the path to your database file
-
Thanks SGaist,
It works now. -
hi every body,
i ve the same issue, should this mean that we don't need to use Q_IMPORT_PLUGIN(qsqlite);
any more for static compiling?