7

I am working for an embedded project, UI developed in QML and backend logic developed using DB/other system calls in C++/Qt.

Which is the best approach to deploy qml files?

Does It adding to .qrc (as resource) and compile to executable application?

or

Load QML files from import folder (QML files will be deployed)?

or any other suggesion?

I have around 200 QML files.

KernelPanic
  • 2,328
  • 7
  • 47
  • 90
Ashif
  • 1,652
  • 14
  • 30
  • With 200 qml files, I suppose the best way is to use the resource file and to compile in a single application. – Tarod Jan 15 '16 at 09:44

1 Answers1

6

QML files in the file system

Files are stored without compression and encryption

  • Faster to build but slower to deploy
  • Stored without compression so they take more storage space
  • Easy to do UI changes on the fly on target (just edit QML and restart)

QML files in the resource file

Resources are compiled to the binary file making the executable file size bigger

  • Slower to build but faster to deploy.
  • Takes less storage space because resources are compressed by default.
  • Because the executable size is bigger the program takes more memory when running.
  • You can't do changes to UI without re-compiling

See from the link the following chapter Managing Resource Files with the Qt Resource System for an example of relative path referencing.

I don't have any strong opinion but here some of my thoughts: If memory usage is an issue then you might go without embedded resources and make sure you use dynamic loading of components as much as possible. In the development phase it's easier to go without embedded resources. If it's a customer project I would do the customer delivery as qml files embedded. This prevents the customer from tweaking the UI code themselves.

talamaki
  • 5,324
  • 1
  • 27
  • 40
  • Good points. Can you please edit your answer to elaborate on "referencing trouble"? It's a bit vague. – Mitch Jan 15 '16 at 16:54
  • Thanks for the update: Now I prefer "QML files in the resource file", if it adds to executable, then launch time takes time, so I am planing to move resources to separate library. – Ashif Jan 18 '16 at 05:03
  • A number of good points, but I have some doubts about "needs more memory as the executable as larger". Under Linux for example I assume the qrc is placed in a custom read-only .elf section. The pages for that are " clean" so the kernel can just drop them if it is in need of memory. – Frank Meerkötter Jan 18 '16 at 07:59
  • @Mitch I don't have any hard evidence, just bad experiences with relative paths from Qt 4. So, I replaced the referencing trouble comment with a link to Qt 5 documentation and example. – talamaki Jan 18 '16 at 09:04
  • @Frank We are talking about the .qrc file compiled into the binary or separate binary resource file, not the .qrc file itself. The Qt resource compiler, rcc, converts the binary data in the .qrc resource file into unsigned char arrays in the qrc_[somename].cpp file, which is then compiled into an object file by the C++ compiler. – talamaki Jan 18 '16 at 09:30