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. How to get item ID from one qml file to other qml file
QtWS25 Last Chance

How to get item ID from one qml file to other qml file

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 2.3k 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.
  • R Offline
    R Offline
    RG90
    wrote on last edited by
    #1

    Hi,

    I am working on some keyNavigation, I have a item(Gridview) in one qml file and want to use keyNavigation for it, I want to assign it to an item which is in other qml file. So, how can I get that item from that qml file and assign it to keynavigation.up:

    Thanks.

    E 1 Reply Last reply
    0
    • R RG90

      Hi,

      I am working on some keyNavigation, I have a item(Gridview) in one qml file and want to use keyNavigation for it, I want to assign it to an item which is in other qml file. So, how can I get that item from that qml file and assign it to keynavigation.up:

      Thanks.

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

      @RG90 It's difficult to follow "item", "it" and "that" in your question, so can you give a code example?

      R 1 Reply Last reply
      0
      • E Eeli K

        @RG90 It's difficult to follow "item", "it" and "that" in your question, so can you give a code example?

        R Offline
        R Offline
        RG90
        wrote on last edited by RG90
        #3

        @Eeli-K

        QML 1 file
        FocusScope{

        id: view
        objectName: "view"
        
        anchors.fill: parent
        
        Flickable{
        
            id: menuFlick
            anchors.fill: parent
            ListView{
        
                id: pages    
            }
        
            GridView
            {
                id: grid
        
                KeyNavigation.up: "itemID" // titlebar to be assigned
                KeyNavigation.priority: {
                    switch(currentIndex) {
                    case 0:
                    case 2:
                    case 4:
                    case 6:
                    case 8:
                    case 10:
                    case 12:
                    case 14:
                    case 16:
                    KeyNavigation.BeforeItem;
                    break;
                    default:
                    KeyNavigation.AfterItem;
                    break;
                    }
            }
        }
        

        }

        QML 2 file
        FocusScope{

        id: titlebar
        focus: true
        anchors.fill: parent
        }
        Note: An these two files are in different folder.

        Now, I want assign titlebar ID of QML 2 file to GridView of first QML 1 file. how can we do it

        E 1 Reply Last reply
        0
        • R RG90

          @Eeli-K

          QML 1 file
          FocusScope{

          id: view
          objectName: "view"
          
          anchors.fill: parent
          
          Flickable{
          
              id: menuFlick
              anchors.fill: parent
              ListView{
          
                  id: pages    
              }
          
              GridView
              {
                  id: grid
          
                  KeyNavigation.up: "itemID" // titlebar to be assigned
                  KeyNavigation.priority: {
                      switch(currentIndex) {
                      case 0:
                      case 2:
                      case 4:
                      case 6:
                      case 8:
                      case 10:
                      case 12:
                      case 14:
                      case 16:
                      KeyNavigation.BeforeItem;
                      break;
                      default:
                      KeyNavigation.AfterItem;
                      break;
                      }
              }
          }
          

          }

          QML 2 file
          FocusScope{

          id: titlebar
          focus: true
          anchors.fill: parent
          }
          Note: An these two files are in different folder.

          Now, I want assign titlebar ID of QML 2 file to GridView of first QML 1 file. how can we do it

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

          @RG90 Where this titlebar is instantiated?

          R 1 Reply Last reply
          0
          • E Eeli K

            @RG90 Where this titlebar is instantiated?

            R Offline
            R Offline
            RG90
            wrote on last edited by RG90
            #5

            @Eeli-K

            titlebar is instantiated in other qml file.

            QML 3 file

            FocuScope{
            id: view

            FocusScope {
            id: main // the QML 1 file is a child of this main element
            }

            Titlebar{
            id: titlebar // over here I am instantiating. which is QML 2 file
            }

            }

            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