Nominate our 2022 Qt Champions!

[SOLVED] Not showing icons in a QTreeView

  • I'm using a QTreeView with a QFileSystemModel. I'd like the QTreeView to not show the icons for files and folders, but even after a lot of searching, I can't find out how to do this. Is there a way?

    EDIT: For some crazy reason, this site isn't letting me post a reply. It says "Error Message: Unable to receive your submission at this time". I tried in two browsers. Anyway thanks, that solution works!

  • Sure.
    class Model : public QFileSystemModel {
    explicit Model(QObject* parent = nullptr) : QFileSystemModel(parent) {}
    QVariant data(const QModelIndex &index, int role) const {
    if(role == Qt::DecorationRole)
    return QVariant();
    return QFileSystemModel::data(index, role);

Log in to reply