I have simple application which show table from sqlite database in QTableView. One column of table is for storing date. I want to provide user easy way to modify date in this column. I have reimplemented data
method of QtSql.QSqlTableModel
to change QVariant
type to QDate
:
class Model(QtSql.QSqlTableModel):
[...]
def data(self, index, role=QtCore.Qt.DisplayRole):
if index.column() == 3:
return super(Model, self).data(index, role).toDate()
return super(Model, self).data(index, role)
[...]
After this change I got column:
But user dont have possibility to have empty date. How can I fix that?
Is it possible to have calendar popup instead of this date edit? Should I use delegate or there is other way go? If delegate is best way, how to set delegate for single QTableView column?