[SOLVED] Build SQLite with Qt5



  • 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.



  • 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.



  • 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.



  • Okay, I found the solution.

    1. I uninstalled Qt
    2. Downloaded the tarball (.tar.gz file containing the source code for Qt (Windows users use the .zip file)).
    3. 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
    @

    1. make and install with this commands:
      @
      make
      @

    after a few frieking hours, then
    @
    sudo make install
    @

    1. 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;
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.