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



  • 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.



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



  • @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



  • @RG90 Where this titlebar is instantiated?



  • @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
    }

    }


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.