Elena
Elena

Reputation: 129

Qt resources in GNU makefile

How to add Qt resources in GNU makefile?

I want to add something like this:

mystyle.qrc

<RCC>
    <qresource prefix="/">
        <file>mystyle.qss</file>
    </qresource>
</RCC>

And it should be used as here:

MyMain.cpp

QFile file(":/mystyle.qss");

Upvotes: 0

Views: 457

Answers (1)

G.M.
G.M.

Reputation: 12879

A simple rule might look something like...

# Specify the `rcc' executable -- `rcc-qt5' on my box but
# may just be `rcc' elsewhere.
#
RCC := rcc-qt5

# Use rcc to generate a .qrc.cpp output file base on the input .qrc
#
%.qrc.cpp: %.qrc
    $(RCC) -name $* -o $@ $<

And then just use the generated .qrc.cpp as you would any other .cpp file. So if your main source file is mp_prog.cpp you could have...

my_prog: my_prog.o mystyle.qrc.o
    $(LD) $(LDFLAGS) -o $@ $+

Assuming the usual builtin rules mystyle.qrc.o will be built from mystyle.qrc.cpp which will, in turn, have been generated from mystyle.qrc using the new rule.

Upvotes: 2

Related Questions