Qt World Summit: Register Today!

I need a connection to my SQL database to my exam project

  • Hi, so I have a problem to connect my db to my project.
    In connection.h I have this:
    #ifndef CONNECTION_H
    #define CONNECTION_H
    #include <QSqlDatabase>
    #include <QSqlError>
    #include <QSqlQuery>
    #include <QtSql>
    #include <QFileInfo>

    class Connection
    bool createconnect();
    void connclose();
    void connopen();

    #endif // CONNECTION_H
    How can I connect the connection.h to my database, which name is "mydb"?
    I am kinda new and a bit lost in all this things and infos.
    Thank you!

  • Lifetime Qt Champion

    It's perfectly described here which params you have to set.

  • Hi and welcome to devnet forum

    The best start for you would be using a Qt creator installation with appropriate Qt lib version. For a starter Qt version 5.15 for the Qt libs is better.

    There are a couple of example projects with SQL available. Try those.

Log in to reply