Reputation: 13711
For many applications, especially on low-performance machines, it is beneficial to have built-in components, such as Loader
and Image
, setup to load their resources asynchronously. To do this, there are two obvious options:
asynchronous: true
AsyncXXX
with basically this content:AsyncXXX.qml:
XXX {
asynchronous: true
}
where XXX is either Loader
or Image
.
I wonder why they are not set to asynchronous mode by default.
Most importantly, is there a way - an environment variable, a global setting - to change the default behaviour of built-in components to the asynchronous one, thus avoiding custom components?
Upvotes: 1
Views: 377
Reputation: 49329
You could easily make ASLoader
and ASImage
QML types which are just Loader
and Image
with asynchronous: true
and use those throughout your project. This will save you on having to modify it everywhere, and if you want to override that, you just go and change it in the prototype.
I wonder why they are not set to asynchronous mode by default.
Asynchronous is always more complicated and with more overhead, so it makes sense if it is not the default behavior. From the QML code I've seen, synchronous is used much more often than asynchronous, so it will make very little sense to make asynchronous default.
EDIT:
You could also achieve switching between synchronous and asynchronous behavior during the runtime if you bind the prototype to a project-wide property, for example a context property, or a property in main.qml
.
Upvotes: 3