KeyNavigation will nicht

Alles rund um die Programmierung mit Qt Quick und QML
Antworten
Ronnic
Beiträge: 2
Registriert: 2. Februar 2021 18:34

KeyNavigation will nicht

Beitrag von Ronnic »

Hallo
ich versuche gerade die Pfeiltasten zur Steurerung vom Focus zu verwenden. Ich kann zwar den Fokus durch anklicken auf ein Rectangle setzen, nicht aber durch verwenden der Pfeiltasten. Was mache ich falsch?

Code: Alles auswählen

Item
{
   id:theUe10Content
   width: 400; height: 200

    Rectangle
    {
       id: lightblue_square
       width: 50; height: 50
       color: (focus ==true)? "red" : "lightblue"

       anchors
       {
            left:parent.left
            top:parent.top
            leftMargin:35
            topMargin:35
       }

       MouseArea
       {
           anchors.fill:parent
           onClicked: parent.focus = true
       }
       KeyNavigation.right: green_square
    }

    Rectangle
    {
        id: green_square
        width: 50; height: 50
        color:focus? "red":"green"
        anchors
        {
             right:parent.right
             top:parent.top
             rightMargin:35
             topMargin:35
        }

        MouseArea
        {
            anchors.fill:parent
            onClicked: parent.focus = true
        }
        KeyNavigation.left:lightblue_square
    }
   }

Antworten