QML: how to save memory on invisible elements?



  • I have a QML Image type and a QML Video type overlaying each other (same sizes).
    At one time, only either of those two elements is visible and needed.

    What's the best way to save memory?

    Should i set the visible property to false?
    Or focus or enabled?

    Thanks for help,
    Ben



  • Use a Loader


  • Moderators

    @ben80 I doubt making them invisible will hardly reduce memory because the item is still loaded in the memory with all its binding and other stuff.
    IMO what you can do is lazy load the item as said by @Sandman using Loader and if you want to save memory then the only way is to delete and create them everytime but it may affect time. So basically you have to do performance vs time profiling.



  • U need to dynamically create object either using loader as already suggested or qt.createcomponent and createobject



  • Ok, Thanks for your answers.
    I will have to switch back and forth all the time. So, i am not sure if i should create them all the time.

    So, that means none of the properties will lead to less memory consumption, right?
    visible, focus, enabled, ...


  • Moderators

    So, that means none of the properties will lead to less memory consumption, right?
    visible, focus, enabled, ...

    AFAIK. Yes.


Log in to reply
 

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