MacOS file system icons have changed
-
You could try to use the native file dialog (it's an option in QFileDialog).
-
My application used to show system icons like this running in MacOS:
Since sometime after Qt 6.0 they now look like this:
Has this change originated with a change in MacOS or Qt? If I run my application in Windows I get the expected windows file system icons.
I can replicate this behavior with a minimal example:
QT += core gui widgets SOURCES += main.cpp
main.cpp
#include <QApplication> #include <QMainWindow> #include <QTreeView> #include <QFileSystemModel> #include <QVBoxLayout> class Explorer : public QMainWindow { public: Explorer(QWidget *parent = nullptr) : QMainWindow(parent) { QFileSystemModel *fileSystemModel = new QFileSystemModel(this); fileSystemModel->setRootPath(QDir::rootPath()); QTreeView *treeView = new QTreeView(this); treeView->setModel(fileSystemModel); treeView->setRootIndex(fileSystemModel->index(QDir::homePath())); treeView->setSortingEnabled(true); QWidget *centralWidget = new QWidget(this); QVBoxLayout *layout = new QVBoxLayout(centralWidget); layout->addWidget(treeView); setCentralWidget(centralWidget); setWindowTitle("File System Explorer"); resize(800, 600); } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); Explorer explorer; explorer.show(); return app.exec(); }
MacOS does not appear to have changed as this is what I see in the finder:
Thanks in advance for any guidance.
@Rory_1 Hi, I built your code.
File icons are OK, folder icons are somewhat "generic". Looks like model gets its decoration role from a different source? I only have the Qt 6.7.2 here so I trust you when you say it's same for different versions. That would also imply something changed in OS libraries from where the Qt gets the icons?
-
@Rory_1 Hi, I built your code.
File icons are OK, folder icons are somewhat "generic". Looks like model gets its decoration role from a different source? I only have the Qt 6.7.2 here so I trust you when you say it's same for different versions. That would also imply something changed in OS libraries from where the Qt gets the icons?
-
You could try to use the native file dialog (it's an option in QFileDialog).
@SimonSchroeder Thanks for the suggestion Simon. My application subclasses QFileSystemModel in order to show the user the count of images in a folder, and displays the QTreeView in a QDockWidget, so using QFileDialog is not going to work. I could substitute the native icons in the QFileSystemModel data update, but I'm hoping for a better solution.
-
It seems that 6.6.3 is not suffering from that issue but indeed 6.7.2 does.
A build from the dev branch however is showing things correctly again so it might already be fixed for 6.8.
-
It seems that 6.6.3 is not suffering from that issue but indeed 6.7.2 does.
A build from the dev branch however is showing things correctly again so it might already be fixed for 6.8.
-
-
Seeing this behavior on Windows with 6.8.3, was there a QTBUG tracking this behavior and/or fix that may have more information?