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. QT Virtual Keyboard in QT Widget
Forum Updated to NodeBB v4.3 + New Features

QT Virtual Keyboard in QT Widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.5k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    aim0d
    wrote on 7 Apr 2023, 09:20 last edited by aim0d 4 Jul 2023, 11:51
    #1

    I'm new to QT and I would like to add to my application the QTVirtual Keyboard and costumize it, but I only found the example from the doc in QML.
    How can I integrated to my QT Widget app?
    (I'm programming for windows, if that is relevant)

    I'm still looking around the internet and here on the Forum and found this This is exactly what I need
    But I noticed that it's an older version of QT.
    I have QT creator 9.0.1 based on qt 6.4

    I also would like to understand how to implement the keyboard opening when click on a QLineEdit

    A 1 Reply Last reply 7 Apr 2023, 11:42
    0
    • A aim0d
      7 Apr 2023, 09:20

      I'm new to QT and I would like to add to my application the QTVirtual Keyboard and costumize it, but I only found the example from the doc in QML.
      How can I integrated to my QT Widget app?
      (I'm programming for windows, if that is relevant)

      I'm still looking around the internet and here on the Forum and found this This is exactly what I need
      But I noticed that it's an older version of QT.
      I have QT creator 9.0.1 based on qt 6.4

      I also would like to understand how to implement the keyboard opening when click on a QLineEdit

      A Offline
      A Offline
      Axel Spoerl
      Moderators
      wrote on 7 Apr 2023, 11:42 last edited by
      #2

      @aim0d Have a look here!

      Software Engineer
      The Qt Company, Oslo

      A 1 Reply Last reply 7 Apr 2023, 11:51
      0
      • A Axel Spoerl
        7 Apr 2023, 11:42

        @aim0d Have a look here!

        A Offline
        A Offline
        aim0d
        wrote on 7 Apr 2023, 11:51 last edited by
        #3

        @Axel-Spoerl Thanks but I already tried looking at the documentation, but could understand how to add it to my app

        A 1 Reply Last reply 7 Apr 2023, 12:19
        0
        • A aim0d
          7 Apr 2023, 11:51

          @Axel-Spoerl Thanks but I already tried looking at the documentation, but could understand how to add it to my app

          A Offline
          A Offline
          Axel Spoerl
          Moderators
          wrote on 7 Apr 2023, 12:19 last edited by
          #4

          @aim0d
          If your platform is supported, you can add the line

          qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
          

          in your main.cpp and the virtual keyboard can be used for all input widgets.

          Software Engineer
          The Qt Company, Oslo

          A 1 Reply Last reply 7 Apr 2023, 12:42
          0
          • A Axel Spoerl
            7 Apr 2023, 12:19

            @aim0d
            If your platform is supported, you can add the line

            qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
            

            in your main.cpp and the virtual keyboard can be used for all input widgets.

            A Offline
            A Offline
            aim0d
            wrote on 7 Apr 2023, 12:42 last edited by
            #5

            @Axel-Spoerl
            Okay, i did it, thanks
            But I have several QLine Edit in my code, how can I call the virtual keyboard when I click on them, and the code for the keyboard is the InputPanel.qml at the end of this page?

            A 1 Reply Last reply 7 Apr 2023, 16:41
            0
            • A aim0d
              7 Apr 2023, 12:42

              @Axel-Spoerl
              Okay, i did it, thanks
              But I have several QLine Edit in my code, how can I call the virtual keyboard when I click on them, and the code for the keyboard is the InputPanel.qml at the end of this page?

              A Offline
              A Offline
              Axel Spoerl
              Moderators
              wrote on 7 Apr 2023, 16:41 last edited by
              #6

              @aim0d
              I apologize, but I don't quite understand. The example mentioned here is QML, the application you mentioned is using widgets. Two different ball games.

              To launch the virtual keyboard when a QLineEdit is clicked or receives focus, the best thing is to intercept a suitable event, which would be QEvent::FocusIn, QEvent::MouseClick or QEvent::MouseButtonPress. That can be done by installing an event filter or subclassing QLineEdit and reimplementing e.g. focusInEvent. Calling QGuiApplication::inputMethod()->show() raises the virtual keyboard (and crashes if there is none, so better check before...). Connecting QLineEdit::textEdited to QGuiApplication::inputMethod()->hide() hides the virtual keyboard once the editing has been finished by pressing return and/or moving focus to another object.

              Software Engineer
              The Qt Company, Oslo

              1 Reply Last reply
              1

              1/6

              7 Apr 2023, 09:20

              • Login

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