start with the QtSQL module
Hi everyone, I'm a beginner in Qt but I'd like to use the QtSQL module but I don't understand anything about the directions given by the documentation.
Can anyone tell me what I need to do to use the QtSQL module, what do I need to install on my computer to use QtSQL?
What version of Qt ?
What OS ?
How did you install Qt ?
I use Qt version 5.10
I am on windows 10
I had downloaded Qt Creator from Qt's official website.
So the QtSql module is already available and you can just start using it like explained here: https://doc.qt.io/qt-5/qtsql-index.html
What kind of database do you plan to use ?
Sorry for the delay in my answer.
actually I want to use MYSQL
Do you have MySQL installed on your machine ?
@SGaist comigo não resultou
comigo não resultou
How is it related to the question at hand ?
@SGaist since I'm also a webmaster so I use phpMyAdmin for the MYSQL database.
@SGaist not result
not result your solution
Get access of all sql modules using
QT += sqlin .pro file of your project.
You can create a database object to create a connection with your database using QsqlDatabase Class
With a created database object, you can use QSqlQuery to insert, update, remove or recover information of your database
Can you try this demo project.
It runs for me and if yours still fail, something is wrong with your Qt install.
create table: true
Hi, here's my source code:
QSqlDatabase m_database = QSqlDatabase::addDatabase("QMYSQL"); m_database.setDatabaseName("127.0.0.1"); m_database.setPort(3306); m_database.setUserName("root"); foreach(QString pilote, m_database.drivers()) qDebug()<< "Pilote: " << pilote; if(m_database.open()) qDebug() << "Connexion réussie.";
and here's the result:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
I guess you are hitting the usual problem: do you have the MySQL client libraries that are accessible by your application ?
I don't know what a MySQL client library is and how to get it and what its importance?
if it is necessary to make simple I know nothing in module QtSQL
so if you can really help me use the QtSQL module, if there are things to download, you can tell me by posting the download link.
The MySQL issue already triggered numerous threads on this forum, you should search for them.