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

Successfully removing keys from the Qt virtual keyboard, sort of.



  • The following code allows me to remove the emoticons key and the language key from the keyboard:

            property var keyboardLayout: virtualKeyboard.keyboard.layout
            
            function disableKey(parent, objectText) {
                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.text === objectText && obj.toString().substring(0, 7) === "BaseKey") {
                        obj.enabled = false
                        obj.visible = false
                    }
                    obj = disableKey(obj, objectText)
                    if (obj)
                        break
                }
                return obj
            }
            
            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(virtualKeyboard.keyboard, "objectName", "changeLanguageKey", null)
                    if(ChangeLanguageKey){
                        ChangeLanguageKey.visible=false
                    }
                    if (keyboardLayout !== "") {
                        disableKey(virtualKeyboard.keyboard, ':-)')
                    }
                }
            }
    

    sort of... The problem is that both keys will return when I click the &123 key and then click the 1/2 key. I believe that is the shift key on the alternative keys page. Would it be possible to eliminate the language key and the emoticon key completely? Is there a better way to remove keys?


  • Moderators



  • @raven-worx Yes I have read that before. It seems to suggest that I would need to import all 43 layouts (if I want each language) and customize them each individually, is that correct?


  • Moderators

    @circuits
    yes, i am not aware of another way to achieve this


Log in to reply