在我的项目中,我有一个 QTreeView 在我的驱动器上显示一个位置。我需要将文件的所有图标更改为自定义图标,但保留文件夹。
我重新实现了 QFileSystemModel 并且能够更改所有图标。有什么方法可以将更改限制为仅文件而不是文件夹?
QVariant MyQFileSystemModel::data(const QModelIndex& index, int role) const
{
if(role == Qt::DecorationRole)
return QPixmap(":/icons/TAG_Int.png");
return QFileSystemModel::data(index, role);
}
这个:
变成:
我怎样才能只更改文件的图标?
谢谢你的时间 :)