How to handle large Qt resource files on a system with very slow storage?

The embedded system has the hardware necessary to run Qt Quick applications, has a good processor and a good graphics processor, but has extremely slow non-volatile memory.

Since the GUI has many images, I have the following dilemma:

  • If I put the images in a qrc file, it will be compiled into an executable file, so the application will load very slowly.
  • if I download images as regular files on demand (not all of them are visible in each menu and in the dialog box), the program will freeze for some time when such a menu or dialog opens, waiting for images to be downloaded from flash memory.
  • Managing individual images manually (for example, in a hand-written background stream) seems too big, so I hope there is a more elegant solution.

Is there a good way to use Qt's resource management system to load resources in the background? Images used in the main GUI should be uploaded while the splash screen displays a good progress bar, and the rest can be uploaded in the background after the main application launch. A nice addition would be if I could selectively load and free certain resource files (in some states of the application some resource files are not needed, so it would be nice if I could free some memory)

Is there an elegant way to solve this problem with the Qt resource system or do I need to manage all my images manually?

+7
c ++ qt
source share
2 answers

It seems useful to note some notes (in my experience):

  • Resource images that will be used as interface resources (for example, icons) must be embedded in the default qrc resource file. They should be small in size.
  • Some resource files are large and will not load often. These resources can be loaded dynamically as external files.
  • You must upload asynchronously large images (using asynchronous ).
  • You must use the Loader element to load large / complex components.
  • You can use UX-solutions / tricks to make the delay invisible (for example, show progress indicators, play micro-animations, transitions, ...).
  • Since I researched for several hours, it seems useful to use dynamic resource files ( rcc files) with / without compression for large resources OR use your own file system.
+1
source share

So you don’t want resources to be embedded in the application because it inflates the executable and loads too slowly, and you don’t want resources outside the application because they are too slow to load?

First of all, being a resource in an executable file does not mean that you are an object ready for use in memory. In most cases, you still have to load this data into a Qt object, such as an image file in QImage . You will still get this delay. And if this piece of data is not unloaded into memory, it will not be faster than reading from disk directly.

The best and almost the only thing you can do is mask the delay. This is only possible if you know what resources are needed for each state of the application, and every time you change the state, you download all the data necessary for the states from which you can switch from the current state. Thus, the resources will be loaded ahead of time, and we hope before you get into a new state that requires this. The disadvantage is that you will need to track these objects, and you will have overhead for memory, since you could load data for several states, but enter only one. Potential - most of the download can be hidden from the user, and you only preload a subset of all the data, not all the data. Naturally, reducing the amount of resources as much as possible is mandatory.

Other than this, you cannot do much. If your storage is slow, the best solution is to upgrade it, if you can, and secondly, be realistic about what you can expect from the hardware.

0
source share

All Articles