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. Creating a lot of the same qml components

Creating a lot of the same qml components

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 1.2k 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.
  • K Offline
    K Offline
    kolegs
    wrote on last edited by
    #1

    Hey,

    I got a question I create a lot of qml components and since there can be even 100 of this objects it takes a lot of time on android devices(even up to 3-4 sec, if the device is slower). All of them are the same objects(same .qml file) with diffrent parameters, is there any better way then just create it? Is it possible to create one empty object(without parameters set) and copy it somehow, I was looking for method to copy QObject but as far as I know its not possible?

    Is there any better way to do it?

    Thanks in advance

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

      Hi,

      Well I'm not aware of any such way but are you creating all the 100 Items at same time Or do you need to show all of them at the same time ?

      157

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kolegs
        wrote on last edited by
        #3

        I create all of them at the same time, and depending on database it can be even more.

        Is it better to load this at once and keep it in memory? Just make in disable?

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

          Loading all items at once will always take some time. Better way would be to load them as and when required and then if they are frequently used keep them loaded.

          157

          1 Reply Last reply
          0
          • GianlucaG Offline
            GianlucaG Offline
            Gianluca
            wrote on last edited by
            #5

            100 or more items for sure does not fit inside the screen together, so you should avoid to load all at once the Item delegated to visualize that information on the screen.
            Qt Quick come in your help with ListView, GridView and TableView. Each of them take a Model (ListModel, or something else) that contains only the data (i.e. the parameters of each item) and usually it's just one object very fast to load even if there is a list of thousands of elements, and then you define a delegate Item that it's your Qt Quick component that takes the parameters and visualize them on the screen.
            ListView (& co.) loads only the Items necessary to get displayed on the screen and in this way there will be only few loading/creation of objects.

            1 Reply Last reply
            0

            • Login

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