Hello,

I want to automatically refresh my table, after I add a new record to the database.

I use a button to bring up a dialog form, in the "accept" button slot I'd like to refresh it before
executing the "accept()" function. But I get an error message that the
model
is not defined in this class.

Qt Code:
  1. void AddClientForm::addclient2db_accept()
  2. { // this is the slot called to accept the entry and INSERT it into the desired table
  3. .... code adding data to db record ...
  4. model->clear();
  5. model->setQuery("SELECT FirstName,LastName,ClientID FROM Clients");
  6. model->setHeaderData(0,Qt::Horizontal, tr("First"));
  7. model->setHeaderData(1,Qt::Horizontal, tr("Last Name"));
  8. model->setHeaderData(2,Qt::Horizontal, tr("Client ID"));
  9.  
  10. accept();
  11. }
To copy to clipboard, switch view to plain text mode 

model is defined in another class, but the above slot is define as shown in this header file:

Qt Code:
  1. /* AddClientForm - Add a new client to the database */
  2. class AddClientForm : public QDialog
  3. {
  4. Q_OBJECT
  5.  
  6. public:
  7. AddClientForm(QWidget *parent=0);
  8.  
  9. private slots:
  10. void addclientform_reset();
  11. void addclient2db_accept();
To copy to clipboard, switch view to plain text mode 

Do I need to inherit the parent class (where the button to add a new record is defined)?


Reference:
http://www.qtcentre.org/forum/f-qt-p...del-21742.html