Just pass the form a pointer to the model. You may do it in the constructor:
class AddClientForm
: public QDialog{
Q_OBJECT
public:
private slots:
void addclientform_reset();
void addclient2db_accept();
private:
class AddClientForm : public QDialog
{
Q_OBJECT
public:
AddClientForm(QSqlQueryModel *model, QWidget *parent=0);
private slots:
void addclientform_reset();
void addclient2db_accept();
private:
QSqlQueryModel *m_model;
To copy to clipboard, switch view to plain text mode
AddClientForm::AddClientForm(model, parent)
m_model = model;
...
}
void AddClientForm::addclient2db_accept()
{ // this is the slot called to accept the entry and INSERT it into the desired table
.... code adding data to db record ...
m_model->clear();
m_model->setQuery("SELECT FirstName,LastName,ClientID FROM Clients");
m_model->setHeaderData(0,Qt::Horizontal, tr("First"));
m_model->setHeaderData(1,Qt::Horizontal, tr("Last Name"));
m_model->setHeaderData(2,Qt::Horizontal, tr("Client ID"));
accept();
}
AddClientForm::AddClientForm(model, parent)
: QDialog(parent) {
m_model = model;
...
}
void AddClientForm::addclient2db_accept()
{ // this is the slot called to accept the entry and INSERT it into the desired table
.... code adding data to db record ...
m_model->clear();
m_model->setQuery("SELECT FirstName,LastName,ClientID FROM Clients");
m_model->setHeaderData(0,Qt::Horizontal, tr("First"));
m_model->setHeaderData(1,Qt::Horizontal, tr("Last Name"));
m_model->setHeaderData(2,Qt::Horizontal, tr("Client ID"));
accept();
}
To copy to clipboard, switch view to plain text mode
AddClientForm *form = new AddClientForm(model, this);
form->show();
AddClientForm *form = new AddClientForm(model, this);
form->show();
To copy to clipboard, switch view to plain text mode
Bookmarks