Qt:如何获取QIcon的文件/资源​​路径 [英] Qt: How to get the file/resource path for a QIcon

查看:2552
本文介绍了Qt:如何获取QIcon的文件/资源​​路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我们假设我做这样的事情:

So let's say I do something like this:

QIcon myIcon(":/resources/icon.ico");

如何稍后确定该图标的路径,例如

How can I later determine the path for that icon, e.g.

QString path = myIcon.getPath();

问题是,没有getPath()成员。我找不到类似的东西,但肯定肯定有办法! :(

The problem is, there is no getPath() member. And I can't find anything similar, but surely there must be a way! :(

我想我可以继承QIcon类并添加这个功能,但它可能是内置的,我可以忽略它?

I guess I could inherit the QIcon class and add this functionality, but it's probably built in and I'm overlooking it?

推荐答案

文件名不存储在 QIcon ,它仅用于构建图像。

The filename isn't stored in QIcon, it's only used for constructing the image.

这篇关于Qt:如何获取QIcon的文件/资源​​路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆