ChrisHBaker
ChrisHBaker

Reputation: 17

Are there default icons for use in a QTreeWidget?

I have a QTreeWidget and I want to add icons, are there a default set to pick from such as the file folder in explorer and a blank piece of paper icon?

Upvotes: 1

Views: 2117

Answers (1)

eyllanesc
eyllanesc

Reputation: 244252

There are several icons by default, for example:

With QStyle::standardIcon(...):

QIcon dir_icon = QApplication::style()->standardIcon(QStyle::SP_DirIcon);
QIcon file_icon = QApplication::style()->standardIcon(QStyle::SP_FileIcon);

with QFileIconProvider::icon(...)

QFileIconProvider provider;
QIcon dir_icon = provider.icon(QFileIconProvider::Folder);
QIcon file_icon = provider.icon(QFileIconProvider::File);

If your OS uses freedesktop then you can use QIcon::fromTheme(...):

QIcon dir_icon = QIcon::fromTheme("folder");
QIcon file_icon = QIcon::fromTheme("text-x-generic")

Upvotes: 6

Related Questions