[Interest] Very large QRC file

Sean Harmer sean.harmer at kdab.com
Wed Mar 23 17:03:22 CET 2016


On Wednesday 23 March 2016 16:57:04 Jason H wrote:
> Not sure. This is an app for a tablet, I've always packaged assets in qrc,
> because it "just worked". I could try DISTFILES, but I'm unsure how that
> work on mobile platforms.
> > Sent: Wednesday, March 23, 2016 at 11:41 AM
> > From: "Gian Maxera" <gmaxera at gmail.com>
> > To: "Jason H" <jhihn at gmx.com>
> > Cc: "interest at qt-project.org Interest" <interest at qt-project.org>
> > Subject: Re: [Interest] Very large QRC file
> > 
> > My absolute rule is Never Never put big files into qrc file.
> > Can you avoid it too ?

No need, just put it into a binary resource file and load that at runtime. That 
avoids the compilation step. Put something like this in your .pro/.pri file:

RCC_BINARY_SOURCES += \
    $$PWD/assets/mybigmedia.qrc

asset_builder.commands = $$[QT_HOST_BINS]/rcc -binary ${QMAKE_FILE_IN} -o 
${QMAKE_FILE_OUT} -no-compress
asset_builder.depend_command = $$[QT_HOST_BINS]/rcc -list 
$$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN}
asset_builder.input = RCC_BINARY_SOURCES
asset_builder.output = $$OUT_PWD/${QMAKE_FILE_IN_BASE}.qrb
asset_builder.CONFIG += no_link target_predeps
QMAKE_EXTRA_COMPILERS += asset_builder

Notice the -no-compress option too this can save runtime CPu costs involved 
with decompressing the data especially for already compressed formats such as 
most video codecs.

Then in your c++ source add:

QResource::registerResource("mybigmedia.qrb");

and use it just like any other resource. Just remember to deploy the qrb file 
with your app.

Cheers,

Sean
--
Dr Sean Harmer | sean.harmer at kdab.com | Managing Director UK
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. UK +44 (0)1625 809908, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions



More information about the Interest mailing list