Using Qt Virtual Keyboard
-
wrote on 11 Jul 2024, 06:44 last edited by
I stumbled upon the docs for Qt Virtual Keyboard sometime recently, but am rather confused on how to use it with C++ and for it to have its expected behavior: scroll the app up if it'll cover something, changing to the numbers-only input, etc.
Are there any additional docs for this?
-
wrote on 12 Jul 2024, 07:11 last edited by
That's the harder version. Of course you have to add the necessary Qt module. Then you have two options:
- You just enable it via
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
This option does not give you any control about where and how it appears. It just appears when your cursor is in a context where text input is possible - If you want to control where it appears and how big it is, you need the InputPanel QML component. AFAIK there is no direct QWidget equivalent, so you will have to wrap it inside a QQuickWidget (I haven't tried that, and I hope that works)
In general, the documentation is very confusing, because there is tons of stuff about customizing the keyboard, adding new input methods, etc. In all that fog, it's hard to find the basic things like "how do I display it?"
- You just enable it via
-
wrote on 11 Jul 2024, 09:05 last edited by
What kind of app do you have? Widget-based or QML-Based?
-
wrote on 11 Jul 2024, 16:44 last edited by
C++, Widget-based.
-
wrote on 12 Jul 2024, 07:11 last edited by
That's the harder version. Of course you have to add the necessary Qt module. Then you have two options:
- You just enable it via
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
This option does not give you any control about where and how it appears. It just appears when your cursor is in a context where text input is possible - If you want to control where it appears and how big it is, you need the InputPanel QML component. AFAIK there is no direct QWidget equivalent, so you will have to wrap it inside a QQuickWidget (I haven't tried that, and I hope that works)
In general, the documentation is very confusing, because there is tons of stuff about customizing the keyboard, adding new input methods, etc. In all that fog, it's hard to find the basic things like "how do I display it?"
- You just enable it via
-
That's the harder version. Of course you have to add the necessary Qt module. Then you have two options:
- You just enable it via
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
This option does not give you any control about where and how it appears. It just appears when your cursor is in a context where text input is possible - If you want to control where it appears and how big it is, you need the InputPanel QML component. AFAIK there is no direct QWidget equivalent, so you will have to wrap it inside a QQuickWidget (I haven't tried that, and I hope that works)
In general, the documentation is very confusing, because there is tons of stuff about customizing the keyboard, adding new input methods, etc. In all that fog, it's hard to find the basic things like "how do I display it?"
wrote on 12 Jul 2024, 15:53 last edited by swurl 7 Dec 2024, 16:19@Asperamanca Alright thanks, will try it soon.
In the meantime I may end up porting my app to QML, in which case I also can't find great docs. Do I need the same
qputenv
thing? - You just enable it via
-
wrote on 16 Jul 2024, 09:31 last edited by
I think the qputenv thing is always needed, but I have not deep-dived into virtual keyboard (yet).
-
wrote on 13 Sept 2024, 18:44 last edited by
This did seem to work.
-