ok now i subclassed QDirModel::data and QDirModel::rowCount as following:
int MyDirModel
::rowCount(const QModelIndex & parent
)const {
}
{
{
if(role == Qt::DisplayRole)
if(role == Qt::DecorationRole)
}
}
int MyDirModel::rowCount(const QModelIndex & parent)const
{
if(parent == QModelIndex())
return QDirModel::rowCount(parent) + 1;
return QDirModel::rowCount(parent);
}
QVariant MyDirModel::data(const QModelIndex & index, int role)const
{
if(index.row() == (QDirModel::rowCount(QModelIndex()) + 1))
{
if(role == Qt::DisplayRole)
return QString(tr("bla"));
if(role == Qt::DecorationRole)
return iconProvider()->icon(QFileIconProvider::Desktop);
return QVariant();
}
return QDirModel::data(index, role);
}
To copy to clipboard, switch view to plain text mode
it does work, however i cannot add an item at the toplevel, only as subentries of other items... I use a treeview to display this, how can i get my item as a toplevel?
edit: the problem seems to be: rowcount isnt called at toplevel
edit 2: it is called... why doesnt it show my additional item then
((
Bookmarks