0

I have TableView and QSqlTableModel as a model for this TableView. They connected as written here (the second method).

I'd like that TableView would refresh its view (data) automatically (when something inserted/updated/removed in the model). How should I do this?

Can I trace somehow all changes in QSqlTableModel (insertion/updating/removing) by one signal? Yes, probably, I can look after rowsInserted, rowsModed and rowsRemoved signals, but may there is one signal for any type of change?

Community
  • 1
  • 1
alr
  • 1,332
  • 3
  • 13
  • 23
  • in your QsqlTableModel class you should emit a **SIGNAL** for ex **dataChanged()** in the **method** where you think changes happened and connect it to a **SLOT** to do what you want to do – Redanium Oct 26 '14 at 09:48

1 Answers1

0

There doesn't seem to be a single signal in QSqlTableModel or its base classes. But I suppose if you don't want to implement a different slot for each signal, you can connect those signals to a custom signal. So every time one of the signals rowsInserted, rowsMoved... are emitted, it will automatically emit your custom signal.

UPDATE: side note: The rowsInserted etc. signals are from the base class QAbstractItemModel. It might be easier to work with QSqlTableModel's signals such as: beforeDelete, beforeInsert etc.