4x4グリッドがあり、矢印キーの押下をグリッド内のアイテムの移動に関連付けたいと思います。どのようにそれを行うのですか?
QMLのサンプルは次のとおりです。
import QtQuick 1.1
Rectangle {
id: main;
width: 500; height: 500;
color: "darkgreen";
property int emptyBlock: 16;
Grid {
id: grid16;
x: 5; y: 5;
width: 490; height: 490;
rows: 4; columns: 4; spacing: 5;
Repeater {
model: 1;
Rectangle {
width: 118; height: 118; color: "darkblue";
}
}
}
Keys.onRightPressed: pressRight();
function pressRight() {
console.log("Left key pressed");
}
focus: true;
}
更新1:回答をくれたsebasgoとalexisdmに感謝します。move
グリッド内での移動がそれほど簡単ではない場合、遷移プロパティ[http://qt-project.org/doc/qt-4.8/qml-grid.html#move-prop]があるのはなぜですか。