3

Both classes offer standard icons for folders and files. Which one should I use? Are they guaranteed to be the same?

sigil
  • 815
  • 8
  • 16

1 Answers1

4

Qt does not strictly guarantee that... In the current implementation, however, QFileIconProvider is a shorthand for using the style. That's unlikely to change soon and it's very logical to do so... Therefore, I stop nitpicking: Yes, it is guaranteed.

Qt is open source so just have a look at the sources: https://github.com/qt/qtbase/blob/dev/src/widgets/itemviews/qfileiconprovider.cpp. There you have

QIcon QFileIconProvider::icon(IconType type) const
{
    Q_D(const QFileIconProvider);
    switch (type) {
    case Computer:
        return d->getIcon(QStyle::SP_ComputerIcon);
//....
QIcon QFileIconProviderPrivate::getIcon(QStyle::StandardPixmap name) const
{
    switch (name) {
    case QStyle::SP_ComputerIcon:
        if (computer.isNull())
            computer = QApplication::style()->standardIcon(name);
        return computer;
//...
Lorenz
  • 503
  • 2
  • 9