I need to sore some value on my system locally and access it later in table format, so I chose QSqlDatabase. And as a first I have to check the database already exist. But using the below code I am always getting the message Data base not exist creating new.... what can be the problem ?
#include <QtCore/QCoreApplication>
#include <QtSql/QSqlDatabase>
#include "QFile"
#include "QDebug"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString dbName = "lprDB";
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
if( QFile::exists(dbName))
{
qDebug()<<"Data base exist....";
}
else {
qDebug()<<"Data base not exist creating new....";
db.setDatabaseName(dbName);
}
return a.exec();
}
db.open(), for creating the DB