I have a Sqlite database that can get changed at any time from another part of my application. I'd like for the UI to be updated automatically as soon as the database is changed. I'm not quite sure how to do this.

So far I'm basing my test app on the "SQL Widget Mapper" demo app.

Qt Code:
  1.  
  2. model = new QSqlTableModel(this,db);
  3. model->setTable("Results");
  4. model->setEditStrategy(QSqlTableModel::OnManualSubmit);
  5.  
  6. mapper = new QDataWidgetMapper(this);
  7. mapper->setModel(model);
  8. mapper->setItemDelegate(new QSqlRelationalDelegate(this));
  9. mapper->addMapping(ui.lineEdit, model->fieldIndex("job_id"));
  10. mapper->addMapping(ui.lineEdit_2, model->fieldIndex("date_time"));
  11.  
  12. connect(ui.pushButton_previous, SIGNAL(clicked()),
  13. mapper, SLOT(toPrevious()));
  14. connect(ui.pushButton_next, SIGNAL(clicked()),
  15. mapper, SLOT(toNext()));
To copy to clipboard, switch view to plain text mode 


I was thinking I could emit a signal whenever the database is changed, but I'm not sure what needs to be informed of the change, and how to do it. Is it the QDataWidgetMapper that needs to know something has changed?

Thanks