Should I get standard icons from QFileIconProvider or QStyle?

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

+3


source to share


1 answer


Qt does not strictly guarantee that ... The current implementation, however, QFileIconProvider

is a shorthand for style use. This is unlikely to change soon, and it is very logical to do ... So I stop picking: Yes, it is guaranteed.

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



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;
//...

      

+4


source







All Articles