#include <QApplication> #include <QDebug> #include <QSqlQuery> #include <QSqlDatabase> #define SQLITE_DATABASE "/QT.db" int main(int argc, char* argv[]) { QApplication a(argc, argv); QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName("SQLITE_DATABASE"); if(db.open()) { qDebug() << "database connect established!"; }else { qDebug() << "build error!"; } return a.exec(); }