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. Key navigation not working

Key navigation not working

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 3 Posters 880 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.
  • J Offline
    J Offline
    JasmineSethi
    wrote on last edited by
    #1

    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
    }
    

    }

    1 Reply Last reply
    0
    • YunusY Offline
      YunusY Offline
      Yunus
      wrote on last edited by
      #2

      @JasmineSethi What is the purpose of this code exaxtly?

      J 1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #3

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

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        J 1 Reply Last reply
        0
        • YunusY Yunus

          @JasmineSethi What is the purpose of this code exaxtly?

          J Offline
          J Offline
          JasmineSethi
          wrote on last edited by JasmineSethi
          #4
          This post is deleted!
          J 1 Reply Last reply
          0
          • dheerendraD dheerendra

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

            J Offline
            J Offline
            JasmineSethi
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • J JasmineSethi

              This post is deleted!

              J Offline
              J Offline
              JasmineSethi
              wrote on last edited by JasmineSethi
              #6
              This post is deleted!
              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