okay... this is the problem of parent and directly using tableview...
do it like this...
void dbDialog::on_pushButton_search_clicked()
{
//instead of creating this again n again.. make it member
layout->setMargin(0);layout->setSpacing(0);
//instead of creating this again n again.. make it member
sqlModel2->clear();
tableView2->setModel(sqlModel2);
layout->addWidget(tableView2);
dlg->exec();
//dlg->show();
//dlg->raise();
//dlg->activateWindow();
}
void dbDialog::on_pushButton_search_clicked()
{
//instead of creating this again n again.. make it member
QDialog* dlg=new QDialog(this);
QVBoxLayout* layout=new QVBoxLayout;
layout->setMargin(0);layout->setSpacing(0);
//instead of creating this again n again.. make it member
QTableView *tableView2;
tableView2 = new QTableView();
sqlModel2 = new QSqlQueryModel();
sqlModel2->clear();
tableView2->setModel(sqlModel2);
layout->addWidget(tableView2);
dlg->exec();
//dlg->show();
//dlg->raise();
//dlg->activateWindow();
}
To copy to clipboard, switch view to plain text mode
you should create your own class inherited from QDialog.
Bookmarks