简体   繁体   中英

Are there default icons for use in a QTreeWidget?

我有一个QTreeWidget,我想添加图标,是否有默认设置可供选择,例如资源管理器中的文件夹和一张空白纸图标?

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM