Details
-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
5.15.0
-
None
Description
Hi guys,
I find that, it is impossible to edit QSqlTable in QML's TableView.
The document said that , use model.edit can locate the edit role, and modify it.
But the fact is that, the QSQlTableModel inherit QSqlQueryModel, but did not rewrite the rolenames function, So it only have DisplayRole. So it can not recognize the "edit" key word.
I inherit QSqlTableModel, and rewrite the rolenames fucntion.added a Edit role, and it works.
// code placeholder QHash<int, QByteArray> MySqlTableModel::roleNames() const { return QHash<int,QByteArray>{ {Qt::DisplayRole, QByteArrayLiteral("display")}, {Qt::EditRole, QByteArrayLiteral("edit")} }; }