How can I get all the images from a qrc file?

I want to get all the images from my qrc file and transfer them to ComboBox. I don’t know what to say more. This is a very simple task, I think, but I cannot find a solution.

+8
qt qcombobox
source share
1 answer

This will lead you to the right path:

foreach( const QString &imageName, QDir(":").entryList() ) { myCombBox->addItem( imageName ); } 

This is if all your images are at the root of your resource file. If they are replaced with names, replace ":" with :/image_namespace

In any case, ":" considered to be the actual directory containing all your resources, and is accessible just like your file system.

+12
source share

All Articles