Answer the question
In order to leave comments, you need to log in
Qt+MySQL. How to connect the database and transfer to other machines along with the program?
Hello. I have exhausted the possibilities of search engines that talk about connecting a MySQL database to Qt, so I'm asking here. I need a database to store information from which Qt will request data. Everything is simple and trivial. But since my experience with the DBMS is extremely small, I do not represent the organization of the entire process. This leads to questions: "Is it possible to supply my MySQL database in *.sql?" program?", "What and where should I shove to make it work?" (in those manuals that I met, only the code in Qt was described, but whether it was necessary to put the database files in the project or somehow connect them was omitted).
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("TestName");//Требуется имя *.slq файла или имя модели БД?
db.setUserName("root");
db.setPassword("");
bool ok = db.open();
QMessageBox::about(nullptr, "Status", (ok) ? "True" : "False");
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question