下面是我用qml编写的一个简单的测试按键的程序,在x86上,用qtcreator 仿真跑的时候一切正常,但是当我交叉编译移植到板子上跑的时候,text死活不响应按键事件 !但是如果我加上 TextEdit 控件后,就可以了。 百思不得其解啊! 拜求高手解答,多谢!
import QtQuick 1.1
Rectangle {
width: 320;
height: 480;
color: "gray";
focus: true;
Keys.enabled: true;
Keys.onEscapePressed: {
Qt.quit();
}
Keys.onDigit0Pressed : {
Qt.quit();
}
Keys.forwardTo: [moveText];
/*
TextEdit{
id:edit
width:200
height: 50
x:50
y:50
color: "blue"
focus: true
}
*/
Text {
id: moveText;
x: 20;
y: 20;
width: 200;
height: 30;
text: "Moving Text";
color: "blue";
// focus: true;
font { bold: true; pixelSize: 24;}
Keys.enabled: true;
Keys.onPressed: {
switch(event.key){
case Qt.Key_Left:
x -= 10;
break;
case Qt.Key_Right:
x += 10;
break;
case Qt.Key_Down:
y += 10;
break;
case Qt.Key_Up:
y -= 10;
break;
default:
return;
}
event.accepted = true;
}
}
}