Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML: how to save memory on invisible elements?

QML: how to save memory on invisible elements?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 4 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    ben80
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SandmanS Offline
      SandmanS Offline
      Sandman
      wrote on last edited by
      #2

      Use a Loader

      1 Reply Last reply
      2
      • p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #3

        @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.

        157

        1 Reply Last reply
        1
        • dheerendraD Online
          dheerendraD Online
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

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

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          6
          • B Offline
            B Offline
            ben80
            wrote on last edited by
            #5

            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, ...

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

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

              AFAIK. Yes.

              157

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved