Performance tip Use Loaders: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
<span class="caps">QML</span> applications can start slowly if there is a lot of <span class="caps">QML</span> to be parsed. This can happen if the whole application is implemented in one huge <span class="caps">QML</span> file. Partition our application wisely into logical entities, load minimum <span class="caps">QML</span> at start and load more as you need it using Loaders.
[[Category:Developing_with_Qt::Qt Quick]]<br />[[Category:Developing_with_Qt::Performance Tips]]


* The Loader item can be used to dynamically load and unload visual <span class="caps">QML</span> components defined in a <span class="caps">QML</span> file or items/components defined within a <span class="caps">QML</span> file. This dynamical behavior allows the developer to control the memory usage and startup speed of an application. More info: http://doc.qt.nokia.com/latest/qml-loader.html#details
QML applications can start slowly if there is a lot of QML to be parsed. This can happen if the whole application is implemented in one huge QML file. Partition our application wisely into logical entities, load minimum QML at start and load more as you need it using Loaders.
* Partition your application into several <span class="caps">QML</span> files so that each file contains a logical UI entity. This way loading and unloading are easier to control. DO <span class="caps">NOT</span> have one huge <span class="caps">QML</span> file per application.
 
* Load absolutely minimum amount of <span class="caps">QML</span> at application start to make your application start as quickly as possible. You can connect to network and show spinner etc. after the application UI is visible.
* The Loader item can be used to dynamically load and unload visual QML components defined in a QML file or items/components defined within a QML file. This dynamical behavior allows the developer to control the memory usage and startup speed of an application. More info: http://doc.qt.nokia.com/latest/qml-loader.html#details
* If your first view is very complex and requires lots of <span class="caps">QML</span> to be loaded, show a splash screen to give user the feeling that something is happening
* Partition your application into several QML files so that each file contains a logical UI entity. This way loading and unloading are easier to control. DO NOT have one huge QML file per application.
* Load absolutely minimum amount of QML at application start to make your application start as quickly as possible. You can connect to network and show spinner etc. after the application UI is visible.
* If your first view is very complex and requires lots of QML to be loaded, show a splash screen to give user the feeling that something is happening
* You should load pieces of UI only by demand e.g. when the user navigates to another view, but on the other hand it may require more time to navigate between views
* You should load pieces of UI only by demand e.g. when the user navigates to another view, but on the other hand it may require more time to navigate between views
* You can use environment variable <span class="caps">QML</span>_IMPORT_TRACE=1 to get debug output from the import loading mechanism. This output clarifies how much <span class="caps">QML</span>/JavaScript code is parsed at application start. http://doc.qt.nokia.com/latest/qdeclarativedebugging.html
===Categories:===
* [[:Category:Developing with Qt|Developing_with_Qt]]
** [[:Category:Developing with Qt::Performance Tips|Performance_Tips]]
* [[:Category:Developing with Qt::Qt Quick|Qt_Quick]]

Revision as of 10:03, 24 February 2015


QML applications can start slowly if there is a lot of QML to be parsed. This can happen if the whole application is implemented in one huge QML file. Partition our application wisely into logical entities, load minimum QML at start and load more as you need it using Loaders.

  • The Loader item can be used to dynamically load and unload visual QML components defined in a QML file or items/components defined within a QML file. This dynamical behavior allows the developer to control the memory usage and startup speed of an application. More info: http://doc.qt.nokia.com/latest/qml-loader.html#details
  • Partition your application into several QML files so that each file contains a logical UI entity. This way loading and unloading are easier to control. DO NOT have one huge QML file per application.
  • Load absolutely minimum amount of QML at application start to make your application start as quickly as possible. You can connect to network and show spinner etc. after the application UI is visible.
  • If your first view is very complex and requires lots of QML to be loaded, show a splash screen to give user the feeling that something is happening
  • You should load pieces of UI only by demand e.g. when the user navigates to another view, but on the other hand it may require more time to navigate between views