I would like to have an Action
which triggers on the shortcut Ctrl+↓.
What I was able to do is have the shortcut for ↓:
Action {
shortcut: StandardKey.MoveToNextLine
enabled: true
onTriggered: console.log('Down pressed')
}
But how can I define the shortcut Ctrl+↓?
From the documentation of shortcut
you read that:
Shortcut bound to the action. The keysequence can be a string or a standard key.
From the QKeySequence
toString()
method documentation you also read that:
Return a string representation of the key sequence, based on format.
For example, the value Qt::CTRL+Qt::Key_O results in "Ctrl+O". If the key sequence has multiple key codes, each is separated by commas in the string returned, such as "Alt+X, Ctrl+Y, Z". The strings, "Ctrl", "Shift", etc. are translated using QObject::tr() in the "QShortcut" context.
Hence, use the key name combination instead of StandardKey
like this:
import QtQuick 2.4
import QtQuick.Window 2.2
import QtQuick.Controls 1.3
ApplicationWindow {
id: rectangle
width: 200
height: 200
visible: true
Action {
shortcut: "Ctrl+Down"
enabled: true
onTriggered: console.log('Down pressed [ctrl hold]')
}
}