#include <QtGui/QApplication>#include "mainwindow.h"#include <QtSql>#include <qsqldatabase.h>#include <QDebug>int main(int argc, char *argv[]){ QSqlQuery query; QApplication a(argc, argv); MainWindow w; a.addLibraryPath( "./" ); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); qDebug() << QSqlDatabase::drivers(); db.setHostName("localhost"); db.setDatabaseName("db1"); db.setUserName("root"); db.setPassword("Djkjlz1"); if (!db.open()) { qDebug() << "Error connecting"; return 1; } else { qDebug() << "Connected"; } if(!query.isActive()) qDebug()<< query.lastError().text(); query.exec("SELECT name FROM region");...
QT += core guiTARGET = monitorTEMPLATE = appSOURCES += main.cpp\ mainwindow.cppHEADERS += mainwindow.hQT += sqlFORMS += mainwindow.ui
QT += sql
#include <QtSql>#include <qsqldatabase.h>... QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");