QT Virtual Keyboard in QT Widget
-
wrote on 7 Apr 2023, 09:20 last edited by aim0d 4 Jul 2023, 11:51
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.4I also would like to understand how to implement the keyboard opening when click on a QLineEdit
-
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.4I also would like to understand how to implement the keyboard opening when click on a QLineEdit
-
wrote on 7 Apr 2023, 11:51 last edited by
@Axel-Spoerl Thanks but I already tried looking at the documentation, but could understand how to add it to my app
-
@Axel-Spoerl Thanks but I already tried looking at the documentation, but could understand how to add it to my app
@aim0d
If your platform is supported, you can add the lineqputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
in your main.cpp and the virtual keyboard can be used for all input widgets.
-
@aim0d
If your platform is supported, you can add the lineqputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
in your main.cpp and the virtual keyboard can be used for all input widgets.
wrote on 7 Apr 2023, 12:42 last edited by@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? -
@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?@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 beQEvent::FocusIn, QEvent::MouseClick
orQEvent::MouseButtonPress
. That can be done by installing an event filter or subclassingQLineEdit
and reimplementing e.g.focusInEvent
. CallingQGuiApplication::inputMethod()->show()
raises the virtual keyboard (and crashes if there is none, so better check before...). ConnectingQLineEdit::textEdited
toQGuiApplication::inputMethod()->hide()
hides the virtual keyboard once the editing has been finished by pressing return and/or moving focus to another object.
1/6