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. Id's that share names

Id's that share names

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 324 Views 2 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.
  • R Offline
    R Offline
    RobM
    wrote on last edited by
    #1

    Lets say I have the following code:

    Item
    {
      id: foo
      Rectangle
      {
        id: red
      }
    }
    
    Item
    {
      id: bar
      Rectangle
      {
        id: red
      }
    }
    

    how is this shared id resolved? I am wondering if I can use the same id for in different places as it would be convenient for me but I don't want them to try to reference one another and I don't want to get the compiler confused. It seems as thought I am allowed to do it but perhaps I shouldn't?

    Pablo J. RoginaP 1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      so, why not simply rename the second id as 'red1' and crack on with what you were doing...?

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      0
      • R RobM

        Lets say I have the following code:

        Item
        {
          id: foo
          Rectangle
          {
            id: red
          }
        }
        
        Item
        {
          id: bar
          Rectangle
          {
            id: red
          }
        }
        

        how is this shared id resolved? I am wondering if I can use the same id for in different places as it would be convenient for me but I don't want them to try to reference one another and I don't want to get the compiler confused. It seems as thought I am allowed to do it but perhaps I shouldn't?

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #3

        @RobM if you're trying to reuse a Rectangle component over and over, you may want to take a look at the QML Camera example, to see how the buttons (Focus, Camera settings, Video control and so on) are created from a base CameraButton component.

        If not, use common sense regarding id naming.

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        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