Key navigation not working



  • i want key navigation for the below project, but its not working. Is the issue with folder structrue or with the code?
    I am writing the key navigation code in ScreenMainMenu. qml and i am loading this screen in main.qml.

    My folder structure is:
    0_1549953191366_410ce78b-a37b-41ea-9cac-5507bda4d92c-image.png

    main.qml:
    import QtQuick 2.2
    import QtQuick.Window 2.0
    import "Screens"

    Window
    {
    id: appWindow
    visible: true
    width: 500
    height: 600

    property var theme: Theme {}
    property var topBar: HeaderBar {}
    property var mainScreen: ScreenMainMenu {}
    Rectangle
    {
        width: 500
        height: 600
        color: theme.background_color
        Loader
        {
            id: firstscreen
            source: "/Screens/ScreenMainMenu.qml"
        }
    }
    

    }
    screenmainmenu.qml:
    Rectangle
    {
    id: screen1
    //To load header for Start Case Menu
    Loader
    {
    id: l1
    source: "/HeaderBar.qml"
    }

    Text
    {
        id: name
        anchors.fill: parent
        text: qsTr("Start Case")
        font.pixelSize: theme.fontpixelSize
        anchors.leftMargin: theme.leftalign
        anchors.topMargin: theme.topmargin
        color: "white"
    }
    
    
    Rectangle
    {
        id: r1
        width: appWindow.width
        height: appWindow.height/10
        //color: "red"
        anchors.top: l1.bottom
    

    //for key navigation
    **color: focus ? "pink" : "lightgray"
    focus: true

        KeyNavigation.down: r2**
    }
    Rectangle
    {
        id: r2
        width: appWindow.width
        height: appWindow.height/10
        color: "white"
        anchors.top: r1.bottom
    }
    

    }



  • @JasmineSethi What is the purpose of this code exaxtly?


  • Qt Champions 2017

    When you loaded the Screenmain.qml did it load ? I don't see any size property for screen.qml.



  • This post is deleted!


  • @dheerendra
    yes it is loading. I am using loader to load ScreenMainMenu.qml in main.qml.



  • This post is deleted!

Log in to reply
 

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