Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to compile qt with sqlite driver on ubuntu



  • hi,
    i used qt with sqlite in Windows and i hadn't problems, but when i tried to develop my project(witch works perfectly in windows) i got some problems, sqlite isn't configured in qt so how can configure it ?

    i'v download libqt4-sql-sqlite from synaptic and i have "libqsqlite.so" and "libqsqlite2.so" files in usr/lib/qt4/plugins/sqldirvers.

    how to compile qt with this driver?



  • Compile qt with this driver?
    If you downloaded the "qt" binaries you should have already the sqlite plugin.
    If you downloaded qt sources and compiled it on ubuntu it will also generate the sqlite plugin.

    I don't see any scenario that you would download the sqlite plugin by itself.

    Can you give us some more details about your issue?



  • i'v solved the probleme, i look that it was a problem with qdir and not with the sqlite driver, im sorry !
    In windows i save my data base in the hoempath() with this code @db.setDatabaseName(QDir::homePath()+"\mydatabase.db3");@ and it work fine but in ubuntu i wrote simply @db.setDatabaseName("mydatabase.db3")@ to work.

    why it didn't work with Qdir ?



  • One of the issues that you should be aware is that the "directory delimiter" is different on Windows and linux. You can use "/" on windows but not "" on linux. Could that be the problem?



  • The backslash is not a valid path delimiter in unix/linux. You should try

    @
    db.setDatabaseName(QDir::homePath()+"/mydatabase.db3");
    @

    This works with Windows too, Qt takes care of translating the slash to backslashes when actually accessing the filesystem.

    Also, is your database file really in your homedir?



  • it works, thank you :)



  • And I recommend use direct slash in Windows too, It also will be work.



  • In fact it is the only one supported in Qt:

    bq. From "QFile":http://doc.qt.nokia.com/stable/qfile.html API docs:
    QFile expects the file separator to be '/' regardless of operating system. The use of other separators (e.g., '') is not supported



  • Volker, Yes, You are right, but unofficially, as I know \ worked in Windows (or worked earlier)


Log in to reply