How to add a default value to QSqlTableModel
-
Hi,
I need to insert a default value (say current unix time stamp), into a QSqlTableModel when a new row is created? Since this column is hidden in the QTableView, no need of delegates to setup, so please give me simple method.
Thanking you,
Ras -
There are two possibilites:
- provide a default value at database level (using a DEFAULT column constraint)
- provide a default value at code level, by connecting to "QSqlTableModel::primeInsert()":http://doc.qt.nokia.com/4.7-snapshot/qsqltablemodel.html#primeInsert