Qt 5.3 Virtual Keyboard to support Ligature



  • I have created Keyboard Layout with GridView and Edit Box with TextInput. Upon pressing any key I am calling a function defined in C++ which is to simulate QKeyEvent to pass to QML Object(TextInput) as if it is happening with the key press on Actual Keyboard. But the problem is with Korean Language on pressing character by character from Virtual Keyboard(GridView), TextInput is not following korean language ligature(Ligatures. In special contexts, some pairs of characters get replaced by a combined glyph forming a ligature. Common examples are the fl and fi ligatures used in typesetting US and European books. http://doc.qt.io/qt-5/internationalization.html) but if the same keys are pressed by actual Keyboard it is working fine. What I am Missing I dont know.

    //C++ Code
    
     Q_INVOKABLE void postKeyValue(int value,QString keyValue)
        {
             event = new QKeyEvent ( QEvent::KeyPress,value, Qt::KeypadModifier,keyValue);
            QObject *myText = (qmleng->rootObjects().first())->findChild<QObject *>(QString("myEdit"));
            if(myText)
            {
                QCoreApplication::postEvent (myText, event);
            }
    }
    
    //QML Code
    
    TextInput {
                id:myEditBox
                property var keyValues:[Qt.Key_Q,Qt.Key_W,Qt.Key_E,Qt.Key_R,Qt.Key_T,Qt.Key_Y,Qt.Key_U,Qt.Key_I,Qt.Key_O,Qt.Key_P,Qt.Key_A,Qt.Key_S,Qt.Key_D,Qt.Key_F,Qt.Key_G,Qt.Key_H,Qt.Key_J,Qt.Key_K,Qt.Key_L,Qt.Key_Z,Qt.Key_X,Qt.Key_C,Qt.Key_V,Qt.Key_B,Qt.Key_N,Qt.Key_M]
                property var keysOnBoard:['ㅂ','ㅈ','ㄷ','ㄱ','ㅅ','ㅛ','ㅕ','ㅑ','ㅐ','ㅔ','ㅁ','ㄴ','ㅇ','ㄹ','ㅎ','ㅗ','ㅓ','ㅏ','ㅣ','ㅋ','ㅌ','ㅊ','ㅍ','ㅠ','ㅜ','ㅡ']
                objectName: "myEdit"
                x:0
                y:0
                width:parent.width
                height:parent.height
                cursorVisible: true
                onAccepted: console.log("onAccepted");
                focus:true
                selectByMouse: true
                anchors.centerIn: parent
                text: qsTr("Korean Keyboard")
                verticalAlignment:   TextInput.AlignVCenter
                horizontalAlignment: TextInput.AlignLeft
                font.pixelSize: 24
                persistentSelection: true
                }
        GridView {
            id: a_z_grid
            anchors.top: myRect.bottom
            anchors.topMargin: 20
            anchors.left: myRect.left
            property bool isNative: true
            x: 20
            y: 77
            width: 780
            height: 403
            cellWidth: 109
            cellHeight: 79
            boundsBehavior: Flickable.StopAtBounds
            model: myEditBox.keysOnBoard.length
            delegate: a_z_gridDelegate
        }
    
        Component{
            id:a_z_gridDelegate
            Rectangle{
                id:myKeys
                width:106
                height:76
                border.color: "black"
                border.width:1
                color:"grey"
                Text{
                    id:myKeyValue
                    anchors.centerIn: parent
                    text:(myEditBox.keysOnBoard.length > index) ?(myEditBox.keysOnBoard[index]):"1"
                    font.pixelSize: 28
                }
               MouseArea{
                  anchors.fill: parent
                  onClicked: PostEvent.postKeyValue(myEditBox.keyValues[index],myEditBox.keysOnBoard[index])
               }
            }
        }
    

    I cant go for QT higher versions as our hardware does not support above QT 5.3. Please somebody help me in this regard. Anything more information is needed to address this issue please ask.



  • @dheerendra

    Can you please help me to find a solution to this problem.


Log in to reply
 

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