I tried to derive a model from QFileSystemModel
, added a CheckBox
to the delegate displayed in a TreeView
and wanted to save the state of the checkbox in the Qt::CheckStateRole. However,
Why is it not possible to use the Qt::CheckStateRole
in a QFileSystemModel
? I added the CheckStateRole to my derived model:
QHash<int,QByteArray> roleNames() const Q_DECL_OVERRIDE
{
QHash<int, QByteArray> result = QFileSystemModel::roleNames();
result.insert(UrlStringRole, QByteArrayLiteral("urlstring"));
result.insert(SizeRole, QByteArrayLiteral("size"));
result.insert(LastModifiedRole, QByteArrayLiteral("lastModified"));
result.insert(IsDirRole, QByteArrayLiteral("isDir"));
result.insert(Qt::CheckStateRole,QByteArrayLiteral("checkState"));
return result;
}
but when in qml I do
console.log('checkstaterole',model.checkState)
in my delegate in qml, it says 'checkstaterole undefined'.
Why is it not possible to use the CheckStateRole in a QFileSystemModel? I thought every model derived from QAbstractItemModel has this role.