Loader vs createObject ?



  • I wish to have QML UI pages that I create and display for switching to different screens. There are two methods to do that namely using a Loader element or dynamically creating your objects using Javascript. What the main pros and cons of these approaches? Its not really laid out in the documentation.



  • Hi Nutcracker,
    Loader can make use of multithreading (property asynchronous: true) and createObject() can't. Note that there is also incubateObject() for asynchronous object creation.



  • Thanks Wieland,
    Yeah so the asynchronous object creation is possible for both. The only major difference which I could find by studying the doc was that the instantiated qml component is destroyed when the Loader's source property is changed but you have complete control of the lifetime of the qml component when you explicitly manage the lifetime via javascript.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.