Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to specify the input method for the Qt Virtual Keyboard?

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

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 4 Posters 4.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • C Offline
        C Offline
        Circuits
        wrote on last edited by Circuits
        #3

        @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?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Circuits
          wrote on last edited by Circuits
          #4

          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.

          1 Reply Last reply
          0
          • Aleksey_KA Offline
            Aleksey_KA Offline
            Aleksey_K
            wrote on last edited by
            #5

            @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!

            jsulmJ 1 Reply Last reply
            0
            • Aleksey_KA Aleksey_K

              @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!

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • Aleksey_KA Offline
                Aleksey_KA Offline
                Aleksey_K
                wrote on last edited by
                #7

                Found the solution. Following workaround works for me:

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

                Works with other controls as well.

                1 Reply Last reply
                3

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved