QtQuick.Controls 2.0 Shortcut behaviour with Popups



  • Hello, I'm working on a QtQuickControls app, and I've noticed some difficult behaviour regarding Shortcut contexts. When using QtQuick.Controls 2.0, Window-specific Shortcuts appear to be overriding each other. My application is entirely key-driven, and consists of multiple Pages/Popups (industrial control panel). I decided on Shortcuts due to their simplicity and lack of focus management. I know that my implementation is legal, since it works with QtQuick.Controls 2.2. A rough outline of the implementation is below.

    ApplicationWindow{
        id: mainWindow
        
        Shortcut{
            objectName: "menuButton"
            context: Qt.WindowShortcut
            sequence: "z"
            onActivated: {
                mainMenu.open()
            }
        }    
    }
    
    Popup{
        id: mainMenu
        anchors.fill: parent
        Rectangle{
            id: rectangle
            color: "#ffffff"
        }
    
        Shortcut{
            id: changeColor
            context: Qt.WindowShortcut
            sequence: "z"
            onActivated: {
                rectanlge.color = "steelblue"
            }
        }
    }
    

    It's a rough implementation, but I've noticed that two Shortcuts with the same sequence will cancel each other out after the first press of that sequence, even if their context are two mutually exclusive windows. Is this a bug? Are there any workarounds? This is working in Qt 5.9.0 with QtQuick.Controls 2.2



  • NEVER MIND: Fixed the problem by way of menuButton.enabled != mainMenu.visible


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.