Answer the question
In order to leave comments, you need to log in
How to connect to MySQL from Qt Creator?
Hello, how to set up a connection to the database in mySQL from Qt Creator. What libraries to include, and how to install them?
Qt Creator 4.6.0 open source
Qt 5.10.1
MySQL 5.7
------------------------------------- ----
something seems to have changed. in the .pro file added an entry "QT += sql"
on the button hung up the event:
QSqlDatabase newDB;
newDB = QSqlDatabase :: addDatabase("QMYSQL");
LIBS += "C:\mysql-5.7\bin"
"C:\mysql-5.7\lib"
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("127.0.0.1");
db.setDatabaseName("test1");
db.setUserName("root");
db.setPassword(" 123123123");
if (!db.open())
QMessageBox::critical(NULL,QObject::tr("Ошибка"),db.lastError().text());
Answer the question
In order to leave comments, you need to log in
Everything was decided after the actions that are described in the question itself.
And also, after all this, I used the advice on the site: https://gromr1.blogspot.ru/2014/04/compiling-drive...
Errors are no longer issued. Maybe someone helped.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question