[SOLVED] Build SQLite with Qt5
-
wrote on 24 Jun 2013, 10:38 last edited by
I have been stuggling for about 4 days to firgure out why my SQL queries does not work. I found out that my drivers are not "loaded" (according to the lastError().text() ). I cant figure out how to make this QSQLite work. I installed Qt5.0.2 and it does not work. Do I need to download the plugin or what? Please help me I am extremely frustrated. I think I need to build the SQlite plugin, but I have no idea how.
Thanks in advance. -
wrote on 24 Jun 2013, 19:21 last edited by
Hi. Qt wants the plugin for manage sqlite archives. The plugins are located in /usr/local/Qt-5.0.2/plugins in my machine for example.
If you want to install your application in a machine without Qt installed you have to copy the right plugin directory, and place it where the application can find it.
You can use qt.conf file to specify the path.
Is not difficoult but if this is your first time with Qt plugins you have to spend some time to learn how those works. -
wrote on 24 Jun 2013, 20:36 last edited by
Maybe this is not util, but yesterday I'd installed Qt 5.0.2 to continued with a project where I use sqlite and is working without problems.
Regards. -
wrote on 3 Jul 2013, 19:55 last edited by
Okay, I found the solution.
- I uninstalled Qt
- Downloaded the tarball (.tar.gz file containing the source code for Qt (Windows users use the .zip file)).
- Configure with this command:
@
./configure -plugin-sql-sqlite
@
or
@
./configure -qt-sql-sqlite
@If it gives you some shit about qtwebkits use just add the following to the configure command:
@
-skip qtwebkit
@- make and install with this commands:
@
make
@
after a few frieking hours, then
@
sudo make install
@- Now this is very important:
when you declare QSqlQuery, declare it after you added the driver, i.e.:
@
QSqlDatabase db;
db = QSqlDatabase::addDatabase( "QSQLITE" );
if( db.open() )
{
QSqlQuery query; //NOTE THIS IS AFTER THE addDatabase("QSQLITE") FUNCTION!
}
@
If for some reason you need the query to be declared earlier (like in a class) do this:
@
QSqlDatabase db;
QSqlQuery query;//This is in another part of the code
db = QSqlDatabase::addDatabase( "QSQLITE" );
if( db.open() )
{
QSqlQuery tmp;
query = tmp;
}
@