1
How can I update a Tableview after closing a Dialog?
Example:
principal.ccp abre conexão com banco de dados
principal::principal(){
//..etc..//
model->setTable("nomeTabela");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->setHeaderData(0, Qt::Horizontal, tr("Lista da tabela"));
model->select();
}
Dialog.cpp Apenas query de insert na tabela nomeTabela
void Dialog::on_cadastroDados_clicked()
{
QSqlQuery qry;
qry.prepare("INSERT INTO nomeTabela/..
qry.addBindValue/...
qry.exec/..
//true
QDialog::Closet();
}
You speak right after closing Dialog. Where would be ?
– Hy-brazil
@user628298 I added an example to answer.
– Lucas Lima
Returned a
error: cannot call member function 'bool QWidget::close()' without object
 if(dcl->exec() == QDialog::close())
 ^
– Hy-brazil
Use the
this->accept()
(in the clase of the dialog) to close. And useQDialog::Accepted
in theif
. If you treat only the case of closing, you will accept when the user opens the dialog and close without making any changes.– Lucas Lima
It worked, thank you very much.
– Hy-brazil