qtqmlqtvirtualkeyboard

Hide key from Qt Virtual keyboard


Is there a way to hide the language selection key from the virtual keyboard without use a custom layout?

enter image description here


Solution

  • I was able to hide the language key with a workaround:

        property var keyboardLayout: inputPanel.keyboard.layout
    
    
        function findChildByProperty(parent, propertyName, propertyValue, compareCb) {
            var obj = null
            if (parent === null)
                return null
            var children = parent.children
            for (var i = 0; i < children.length; i++) {
                obj = children[i]
                if (obj.hasOwnProperty(propertyName)) {
                    if (compareCb !== null) {
                        if (compareCb(obj[propertyName], propertyValue))
                            break
                    } else if (obj[propertyName] === propertyValue) {
                        break
                    }
                }
                obj = findChildByProperty(obj, propertyName, propertyValue, compareCb)
                if (obj)
                    break
            }
            return obj
        }
    
    
    
        onKeyboardLayoutChanged: {
            if(keyboardLayout!=""){
                var ChangeLanguageKey= findChildByProperty(inputPanel.keyboard, "objectName", "changeLanguageKey", null)
                if(ChangeLanguageKey){
                    ChangeLanguageKey.visible=false
                }
            }
        }
    
    
        InputPanel {
            id: inputPanel
            z: 99
            y: parent.height
            anchors.left: parent.left
            anchors.right: parent.right
    
    
    
    
            states: State {
                name: "visible"
    
                when: inputPanel.active
                PropertyChanges {
                    target: inputPanel
                    y: parent.height - inputPanel.height
                }
            }
            transitions: Transition {
                from: ""
                to: "visible"
                reversible: true
                ParallelAnimation {
                    NumberAnimation {
                        properties: "y"
                        duration: 400
                        easing.type: Easing.InOutBack
                    }
                }
            }
    
    
    
    
    
            CustomComponents.AutoScroller {
    
                id:autoscroller
    
                panelY: inputPanel.y
            }
    
    
        }
    

    enter image description here

    This only works in version 5.9 where the objectname property is defined with "changeLanguageKey", for previous versions set the property in the source code and recompile.