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. Recover id in variable
Forum Updated to NodeBB v4.3 + New Features

Recover id in variable

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 443 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.
  • T Offline
    T Offline
    Titi01
    wrote on last edited by
    #1

    Buttons.qml

    Rectangle {
        width:60
        height: 80
       
        MouseArea{
            anchors.fill:parent
            onClicked: {
                    
                 loader.source="nextFile.qml"
                /* 
    I would like to retrieve here the id (in a variable) of my button which is defined in the main.qml */
    
            }
    
    

    main.qml

    Buttons{
        id: id1
         color:"red"
         x:150
         y:150
    }
    Buttons{
        id: id2
         color:"blue"
         x:200
         y:200
    }
    

    I would like to retrieve the id in a variable in onCliked {} but the id is in the main.qml and not in the Buttons.qml

    thanks you

    E 1 Reply Last reply
    0
    • T Titi01

      Buttons.qml

      Rectangle {
          width:60
          height: 80
         
          MouseArea{
              anchors.fill:parent
              onClicked: {
                      
                   loader.source="nextFile.qml"
                  /* 
      I would like to retrieve here the id (in a variable) of my button which is defined in the main.qml */
      
              }
      
      

      main.qml

      Buttons{
          id: id1
           color:"red"
           x:150
           y:150
      }
      Buttons{
          id: id2
           color:"blue"
           x:200
           y:200
      }
      

      I would like to retrieve the id in a variable in onCliked {} but the id is in the main.qml and not in the Buttons.qml

      thanks you

      E Offline
      E Offline
      Eeli K
      wrote on last edited by
      #2

      @Titi01 Id's are special, they don't work like other properties. You have to explain what you want to achieve. Also you can't use id's declared in your main.qml in Buttons.qml.

      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