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

Virtual keyboard not visible



  • I have a sample application which has scrollable text area and input panel. When user clicks on text area, keyboard should appear and height of text area should be adjusted.
    1. I see that first time when I click on text area, keyboard is not visible! Click again and keyboard comes up.
    2. Also, I see a binding loop error: qrc:/main.qml:6:1: QML QQuickWindowQmlImpl*: Binding loop detected for property "conclusionAreaHeight"*

    Please share your suggestions.

    import QtQuick 2.9
    import QtQuick.Window 2.2
    import QtQuick.Controls 2.2
    import QtQuick.VirtualKeyboard 2.2
    
    Window {
        visible: true
        width: 1280
        height: 480
        title: qsTr("Hello World")
    
        property int conclusionAreaHeight: Qt.inputMethod.visible ? 85 : 480
        property int conclusionLength: 511
    
        Rectangle{
            color: "white"
            border.color: "#eeeeee"
            height: conclusionAreaHeight
            width: 1000
            anchors.margins: 15
            anchors.horizontalCenter: parent.horizontalCenter
            ScrollView {
                id: conclusionViewId
                anchors.fill: parent
                contentWidth: conclusionViewId.width - 35
                clip: true
    
                TextArea {
                    id: conclusionTextAreaId
                    wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
                    focus: false
    
                    property string previousText: text
    
                    /*to limit no. of characters*/
                    /*Text area does not have validator property, hence the work around*/
                    /*Refer https://bugreports.qt.io/browse/QTBUG-12304*/
                    onLengthChanged: {
                        if(length > conclusionLength){
                            var cursor = cursorPosition;
                            text = previousText;
                            if (cursor > text.length) {
                                cursorPosition = text.length;
                            } else {
                                cursorPosition = cursor-1;
                            }
                        }
                        previousText = text
                    }
                }
            }
        }
    
    
        InputPanel{
            id: keyboardId
            width: 800
            visible: active
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
        }
    }
    
    

Log in to reply