Using Qt Virtual Keyboard
-
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?
-
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
-
What kind of app do you have? Widget-based or QML-Based?
-
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?"
@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
-
I think the qputenv thing is always needed, but I have not deep-dived into virtual keyboard (yet).
-