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

How to specify the input method for the Qt Virtual Keyboard?



  • Is there a way for me to specify what the input method is for the Qt Virtual Keyboard? For instance could I send the text to a simple Text{} QML Type? For instance, take a look at the following code:

    Rectangle
    {
        id: display
        color: "white"
        width: 300
        height: 50
        radius: 5
        x: 100
        anchors.bottom: virtualKeyboard.top
        Text
        {
            id: entryDisplay
            width: parent.width - 50
            anchors.centerIn: display
            color: "black"
            text: "qwertyuiopasdfghjklz" //want to funnel keyboard input here
        }
    }
    InputPanel{
        id: virtualKeyboard
        width: messageContainer.width - control.style.padding * 2
        anchors.centerIn: messageContainer
        active: true
    }
    

    I would like entryDisplay's text property to be the location for they keyboard to display it's text. Is that possible? I want to avoid using an actual TextInput if possible.


  • Lifetime Qt Champion

    Hi,

    Set the QT_IM_MODULE environment variable before starting your application or creating your QGuiApplication object if you do it in code.

    QT_IM_MODULE=qtvirtualkeyboard
    

    More information here.



  • @SGaist I am not sure I understand. I have the keyboard working already, that isn't the problem. The problem is I want to display the input in the text property of a QML Text{} type rather than by using the TextInput{} type.

    Basically, I display this keyboard on a button press rather than by using a TextInput{}. That button press creates a component that houses the keyboard. So now I want to display the results of a key press in an area that is not clickable, in this case a simple Text{} type.

    I already have the QT_IM_MODULE environment variable set. In other words, currently when I press a key on the keyboard it reports an error:

    input method is not set
    

    can I set this "input method" to be my Text{} type's text value?



  • So far I have found: TextArea{}, TextEdit{}, TextInput{} and TextField{} will all grab the keyboard's focus when clicked.

    Is there a way to specify the keyboards focus? I dont want to user to have to click a box in order to grab the keyboards focus.



  • @Circuits said in How to specify the input method for the Qt Virtual Keyboard?:

    input method is not set

    Same bug as well as many people for years!!!

    Google search

    Any solution yet?! Qt company, are you going to fix this somehow>?! Very boring!!! qt virtual keyboard worked for me with TextArea, then accidentally it stopped and I started to get these strange errors: input method is not set . Reason is unclear!


  • Lifetime Qt Champion

    @Aleksey_K said in How to specify the input method for the Qt Virtual Keyboard?:

    Any solution yet?! Qt company, are you going to fix this somehow>?!

    No point to ask this here as this is user forum.
    Either ask on Qt developers mailing list or file a bug in Qt bug tracker.



  • Found the solution. Following workaround works for me:

    TextArea {
        onActiveFocusChanged: {
            if(activeFocus) {
                Qt.inputMethod.update(Qt.ImQueryInput)
            }
        }
    }
    

    Works with other controls as well.


Log in to reply