Answer the question
In order to leave comments, you need to log in
How to pass a db connection to another class in QT?
How to pass a db connection to another class in QT?
Created a separate class for connecting to Sqlite DB.
SqliteConnection::SqliteConnection()
{
}
void SqliteConnection::OpenConnection(){
db_sqlite = QSqlDatabase::addDatabase("QSQLITE");
db_sqlite.setDatabaseName("samples.db");
db_sqlite.open();
if(db_sqlite.isOpen()){
qDebug()<<"Ok";
}
}
void SqliteConnection::CloseConnection(){
db_sqlite.close();
}
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