Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Shortcuts & QtQuick.Controls



  • Hi guys & gals,

    I got confused with QML Shortcuts... Here is a trivial example with Qt 5.14 / QtQuick.Controls 2.14:

    ApplicationWindow {
        Shortcut {
            sequence: "Ctrl+U"
            onActivated: print("/shortcut/ activated")
        }
        TextField {}
    }
    

    I expect the Shortcut to be activated every time I press Ctrl+U, no matter what. However, when the TextField receives the active focus, it seems to consume the Ctrl+U combination to perform an undo operation. I would do Keys.forwardTo and use the Shortcut as a target if it were possible but Shortcut isn't an Item.

    So, the Shortcut isn't at the top of the priority list, is it? Is there any sophisticated way to ensure that the Shortcut is triggered no matter what happens, i.e. no matter where the active focus is?


Log in to reply