Hide key from Qt Virtual keyboard

点点圈 提交于 2019-12-30 11:24:27

问题


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


回答1:


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
        }


    }

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.




回答2:


No, not without using a custom layout.

You can always modify the layouts that come with the keyboard though.



来源:https://stackoverflow.com/questions/42834050/hide-key-from-qt-virtual-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!