Hello, I am calling a method in another class, after the insertion of data. But this returning an error SQLite :
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.
To copy to clipboard, switch view to plain text mode
Source:
insert_sales.cpp
void DialogSales::insert_sale(){
//QSqlQuery
if (qry.lastInsertId()>0){
QMessageBox::information(this,
"Register",
"Registered successfully.");
MainSystem *ms= new MainSystem(this);
ms->tableView_listSales();
}
}
void DialogSales::insert_sale(){
//QSqlQuery
if (qry.lastInsertId()>0){
QMessageBox::information(this,"Register", "Registered successfully.");
MainSystem *ms= new MainSystem(this);
ms->tableView_listSales();
}
}
To copy to clipboard, switch view to plain text mode
MainSystem.cpp
ui->setupUi(this);
base = new connection(NAME_BASE);
if(!base->openBD()){
return;
}
}
void MainSystem::tableView_listSales(){
model->setQuery("SELEC * FROM inventory WHERE strftime('%Y-%m-%d', inventory_date)='"+dateTime.toString("yyyy-MM-dd")+"'");
model->setHeaderData(0, Qt::Horizontal, tr("Client"));
model->setHeaderData(1, Qt::Horizontal, tr("Address"));
model->setHeaderData(3, Qt::Horizontal, tr("Payment"));
model->setHeaderData(6, Qt::Horizontal, tr("Date"));
ui->tableView_sales->setModel(model);
}
MainSystem::MainSystem(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainSystem){
ui->setupUi(this);
base = new connection(NAME_BASE);
if(!base->openBD()){
QMessageBox::critical(this, "Erro", ERRO_BASE);
return;
}
}
void MainSystem::tableView_listSales(){
model = new QSqlQueryModel;
model->setQuery("SELEC * FROM inventory WHERE strftime('%Y-%m-%d', inventory_date)='"+dateTime.toString("yyyy-MM-dd")+"'");
model->setHeaderData(0, Qt::Horizontal, tr("Client"));
model->setHeaderData(1, Qt::Horizontal, tr("Address"));
model->setHeaderData(3, Qt::Horizontal, tr("Payment"));
model->setHeaderData(6, Qt::Horizontal, tr("Date"));
ui->tableView_sales->setModel(model);
}
To copy to clipboard, switch view to plain text mode
Bookmarks