import QtQuick 2.5 import fbx.application 1.0 Application { color: "white" property int aX : 50 property int aY : 50 Rectangle { id: bluerect width: 20; height: 20 color: "blue" radius: width/2 x: 500 y: 500 } Rectangle { id: greenrect width: 20; height: 20 color: "green" radius: width/2 x: 250 y: 250 } Rectangle { id: redrect width: 20; height: 20 color: "red" radius: width/2 x: 750 y: 250 } Rectangle { focus: true id: rect width: 20; height: 20 radius: width/2 color: "red" x: aX y: aY Keys.onRightPressed: aX += 10 Keys.onLeftPressed: aX -= 10 Keys.onUpPressed: aY-= 10 Keys.onDownPressed: aY+= 10 Keys.onReturnPressed: { if((rect.x === bluerect.x) && (rect.y === bluerect.y)) rect.color = bluerect.color else if((rect.x === greenrect.x) && (rect.y === greenrect.y)) rect.color = greenrect.color else if((rect.x === redrect.x) && (rect.y === redrect.y)) rect.color = redrect.color } } }