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? -
Hi,
What version of Qt ?
What OS ?
How did you install Qt ? -
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 ?
-
Do you have MySQL installed on your machine ?
-
@123456789 said in start with the QtSQL module:
comigo não resultou
How is it related to the question at hand ?
-
@123456789
Get access of all sql modules usingQT += sql
in .pro file of your project.You can create a database object to create a connection with your database using QsqlDatabase Class
http://doc.qt.io/qt-5/sql-connecting.html
With a created database object, you can use QSqlQuery to insert, update, remove or recover information of your database
-
Hi
Can you try this demo project.
It runs for me and if yours still fail, something is wrong with your Qt install.
https://www.dropbox.com/s/uo43f7sbiwcjazv/mySqlite.zip?dl=0output:
create table: true
"Young"
"Holand"
"Gordon"
"Robitaille"
"Papadopoulos" -
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 loadedQSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
Pilote: "QSQLITE"
Pilote: "QMYSQL"
Pilote: "QMYSQL3"
Pilote: "QODBC"
Pilote: "QODBC3"
Pilote: "QPSQL"
Pilote: "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.