Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify wildcards in .qrc resource file of QML?

There are x number of .png files in a directory.
Instead of adding all these manually I would want to specify the directory path in the .qrc file and let it include all of them on its own.

What is the way to achieve this?

like image 381
Aquarius_Girl Avatar asked Jan 14 '15 07:01

Aquarius_Girl


3 Answers

Here is a little bash script that generate a qrc file from the content of a folder

#!/bin/sh
QRC=./resourcefilename.qrc
echo '<!DOCTYPE RCC>' > $QRC
echo '<RCC version="1.0">' >> $QRC
echo '  <qresource>' >> $QRC

# for each files/folder in the folder "theFokderName"
for a in $(find theFolderName -d)
do
    # if this is not a folder
    if [ ! -d "$a" ]; then
        echo '      <file>'$a'</file>' >> $QRC
    fi
done

echo '  </qresource>' >> $QRC
echo '</RCC>' >> $QRC

You can easily customize it.

like image 175
frachop Avatar answered Oct 23 '22 04:10

frachop


No, this is not yet possible, see this bugreport for details.

like image 42
Thomas McGuire Avatar answered Oct 23 '22 02:10

Thomas McGuire


Just for documentation, I found a workaround to this on this link.

The following entry in project.pro ensures that the resources are built into the application binary, making them available when needed:

RESOURCES += \
    qml/main.qml \
    images/image1.png \
    images/image2.png

A more convenient approach is to use the wildcard syntax to select several files at once:

RESOURCES += \ 
    $$files(qml/ *.qml) \
    $$files(images/ *.png)

So, if you use $$file(wildcard) on your .pro file, it would work. I tried and it worked OK.

like image 2
Cmorais Avatar answered Oct 23 '22 03:10

Cmorais