qrc路径_在Qt中获取qrc文件的路径

本文介绍了在Qt中如何获取qrc文件中文件的路径。通过使用QDirIterator和QXmlStreamReader两种方式,可以有效地读取并使用qrc文件内的图片路径。
摘要由CSDN通过智能技术生成

I want to know how to access the paths of files in the qrc file in order to use them as strings in an array.

An example of qrc file is:

images/1.jpg

images/2.jpg

images/3.jpg

images/4.jpg

I want to use it in the following manner:

for(int i=0;i<4;i++)

{

path=image_path[i];

}

where path is an qlist that can be later used for accessing the respective images.

解决方案

There seems to be a simple way of doing it using QDirIterator.

It might break if you have a directory called ":" in the current working directory and you expect that to be parsed instead in the future. Anyhow, that should not be a concern for now.

QStringList imageFileList;

QDirIterator dirIterator(":", QDirIterator::Subdirectories);

while (dirIterator.hasNe

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值