Answer the question
In order to leave comments, you need to log in
How to put the database together with the application?
if(QFile::exists(":db/db.sl3")){
QSqlDatabase b = QSqlDatabase::addDatabase("QSQLITE");
b.setDatabaseName(":db/db.sl3");
qDebug()<<"Database: ";
if(!b.open()){
qDebug()<<b.lastError().text();
}else{
qDebug()<<"All ok select sqlite_version() AS sqlite_version";
}
}else{
qDebug()<<"File not found";
}
Answer the question
In order to leave comments, you need to log in
Just copied from qrc to AppDataLocation
QStandardPaths::standardLocations(QStandardPaths::AppDataLocation);
if(!QFile::exists("db.sl3")){
QFile::copy(":db/db.sl3","db.sl3");
}else{
qDebug()<<"File found"; }
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
nwtb.setDatabaseName("JWS.sl3");
if(!db.open()){
qDebug()<<nwtb.lastError().text();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question