I have QWidget with tableView and QDialog with textEdit and button

In the QDialog i enter a data and when click on the button it adds a new record in the QSqlQueryModel (i'm using SQLite).
I add the data correctly, but i need to update the tableView in order to display the new record.I read in the internet that it should automatically update it, but it doesn't.

What i make is call a signal when the new record is inserted in the model.Than i connect it to a slot in the QWidget:

Qt Code:
  1. Partners::Partners(QWidget *parent) :
  2. QWidget(parent),
  3. ui(new Ui::Partners)
  4. {
  5. ui->setupUi(this);
  6.  
  7.  
  8. model->setQuery("SELECT Name, City, Bulstat FROM partners");
  9. model->setHeaderData(0, Qt::Horizontal, QObject::tr("Име"));
  10. model->setHeaderData(1, Qt::Horizontal, QObject::tr("Град"));
  11. model->setHeaderData(2, Qt::Horizontal, QObject::tr("ЕИК:"));
  12.  
  13. ui->tableView_partners->setModel(model);
  14. ui->tableView_partners->setColumnWidth(0,299);
  15. ui->tableView_partners->setColumnWidth(1,225);
  16. ui->tableView_partners->setColumnWidth(2,225);
  17. ui->tableView_partners->horizontalHeader()->sectionResizeMode(QHeaderView::Interactive);
  18. ui->tableView_partners->horizontalHeader()->setStretchLastSection(true);
  19.  
  20. }
  21.  
  22. Partners::~Partners()
  23. {
  24. delete ui;
  25. }
  26.  
  27.  
  28. void Partners::updatePartnersTable()
  29. {
  30. //the code which update the table should be here
  31. qDebug() << "updated";
  32. }
To copy to clipboard, switch view to plain text mode