I want to get all images from my qrc file and pass them to a ComboBox. Don't know what to say more. It's a very basic task I think but I can't find a solution.
Asked
Active
Viewed 2,953 times
1 Answers
13
This should get you on the right track:
foreach( const QString &imageName, QDir(":").entryList() )
{
myCombBox->addItem( imageName );
}
This is if all of your images are at the root of your resource file. If they're namespaced then replace ":"
with :/image_namespace
Either way, the ":"
is treated as an actual directory containing all of your resources and is accessible in the same way as your file system.

Chris
- 17,119
- 5
- 57
- 60
-
Did this work? QDir should not be able to iterate on resources. – sorush-r Aug 19 '16 at 12:22
-
Why not? http://doc.qt.io/qt-5/qdir.html "It can also be used to access Qt's resource system." – Chris Aug 20 '16 at 01:59