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. Use an instance of a Component on two Pages
Forum Updated to NodeBB v4.3 + New Features

Use an instance of a Component on two Pages

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 3 Posters 2.2k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    talmage
    wrote on last edited by
    #1

    Is it possible to use the same instance of a displayable Component like a Rectangle in two different places. For example, on two different Pages on a PageStackWindow? If so, what's the syntax?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      No, but you can reparent an item when needed.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        talmage
        wrote on last edited by
        #3

        Can I do that by assignment

        @
        component_id.parent = new_parent_id
        @

        or must I use a State change and the ParentChange element?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          talmage
          wrote on last edited by
          #4

          I tried it with interesting results.

          Reparenting by assignment worked!

          Reparenting by changing state and using a ParentChange did not work. The Component did not appear at all. I tried this with a simple red rectangle and this, too, failed. Is there something magical about PageStackWindow and Page that prevents this from working?

          Thank you for helping me, Andre.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            srikanth_trulyit
            wrote on last edited by
            #5

            Looks like a good optimization at-least in my case. We are facing performance problems when qml items are created dynamically. I will do some r&d to see if we can recycle and use the created items. Please do share your updates about this.

            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