This is what I did now:
In header file:
class MyQFileSystemModel : public QFileSystemModel {
public:
};
class MyQFileSystemModel : public QFileSystemModel {
public:
QVariant data(const QModelIndex &index, int role) const;
};
To copy to clipboard, switch view to plain text mode
In cpp File:
QVariant MyQFileSystemModel
::data( const QModelIndex
& index,
int role
) const {
if( role == Qt::DecorationRole ) {
}
return QFileSystemModel::data(index, role);
}
QVariant MyQFileSystemModel::data( const QModelIndex& index, int role ) const {
if( role == Qt::DecorationRole ) {
return QVariant(QIcon(QPixmap(":\\P2Viewer\\Foldericon.PNG")));
}
return QFileSystemModel::data(index, role);
}
To copy to clipboard, switch view to plain text mode
Inside the constructor:
MyQFileSystemModel* model = new MyQFileSystemModel;
model
->setRootPath
(QDir::currentPath());
ui->SecoTreeView->setModel(model);
MyQFileSystemModel* model = new MyQFileSystemModel;
model->setRootPath(QDir::currentPath());
ui->SecoTreeView->setModel(model);
To copy to clipboard, switch view to plain text mode
This changes the foldericon but also changes the icon of C: or D: drive. Basically I want to use 2 icons... One for folders within drives and other for the drive.
Originally Posted by
wysota
No, we don't know that. If you mean the folder icon then on my system it is not yellow.
You can subclass the model and reimplement its data() method to return an icon of your choice or you can provide a custom delegate that will render each item in a way you like. And no, there is no QMakeMyFolderIconBlueDelegate class, you have to write it yourself.
Bookmarks