Keys QML Type

Provides key handling to Items. 更多...

导入语句: import QtQuick .
Since: Qt Quick Ultralite 1.0

信号

详细描述

All visual primitives support key handling via the Keys attached property. Key input can be handled via the onPressed and onReleased signal handlers.

These signal handlers have a event parameter, which contains details about the KeyEvent .

用法范例

The following example shows how the general onPressed handler can be used to test for a certain key:

Item {
    anchors.fill: parent
    Keys.onPressed: {
        if (event.key == Qt.Key_Left) {
            console.log("move left");
        }
    }
}
						

Qt::Key for the list of keyboard codes.

注意: Key events are emitted only when you build and run the application for the Qt desktop backend.

另请参阅 KeyEvent .

信号文档编制

pressed ( KeyEvent event )

This signal is emitted when a key has been pressed. The event parameter provides information about the event.

注意: 相应处理程序是 onPressed .

注意: 相应处理程序是 onPressed .


released ( KeyEvent event )

This signal is emitted when a key has been released. The event parameter provides information about the event.

注意: 相应处理程序是 onReleased .

注意: 相应处理程序是 onReleased .