QIcon::fromTheme

英文官方文档说明:

https://doc.qt.io/qt-5/qicon.html#themeName

英文官方文档摘抄部分,版权归原作者,笔者无版权,如下:

QIconfromTheme(const QString &name)
QIconfromTheme(const QString &name, const QIcon &fallback)

 

QIcon QIcon::fromTheme(const QString &name)

Returns the QIcon corresponding to name in the current icon theme.

The latest version of the freedesktop icon specification and naming specification can be obtained here:

To fetch an icon from the current icon theme:

    QIcon undoicon = QIcon::fromTheme("edit-undo");

Note: By default, only X11 will support themed icons. In order to use themed icons on Mac and Windows, you will have to bundle a compliant theme in one of your themeSearchPaths() and set the appropriate themeName().

Note: Qt will make use of GTK's icon-theme.cache if present to speed up the lookup. These caches can be generated using gtk-update-icon-cache: https://developer.gnome.org/gtk3/stable/gtk-update-icon-cache.html.

Note: If an icon can't be found in the current theme, then it will be searched in fallbackSearchPaths() as an unthemed icon.

This function was introduced in Qt 4.6.

See also themeName(), setThemeName(), themeSearchPaths(), and fallbackSearchPaths().

[static]QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)

This is an overloaded function.

Returns the QIcon corresponding to name in the current icon theme. If no such icon is found in the current theme fallback is returned instead.

If you want to provide a guaranteed fallback for platforms that do not support theme icons, you can use the second argument:

    QIcon undoicon = QIcon::fromTheme("edit-undo", QIcon(":/undo.png"));

 

 

另外可以参考:【Qt】QIcon::fromTheme:从系统主题中获取图标

https://blog.csdn.net/u010168781/article/details/88558858

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值