hi,
I am trying to create a simple Qt application which is used virtual keyboard to enter data to a lineedt.
Could you please help me out to integrate the virtual keyboard to Qt ?
Thanks in Advance.
Regards
Vinithr
hi,
I am trying to create a simple Qt application which is used virtual keyboard to enter data to a lineedt.
Could you please help me out to integrate the virtual keyboard to Qt ?
Thanks in Advance.
Regards
Vinithr
You have your own virtual keyboard ? Or how do you plan to use it ?
Well you can show a custom widget as a virtual keyboard. You will need to derive your own class from QInputContext.
In the filterEvent you can show the input panel.
You will also need to set the input context to your application QApplication::setInputContext
There was also some Qt example related to input context. You can search for it too.
vinithr (11th June 2012)
Thanks for your reply..
Well i am planning to use full keyboard only. I found the input panel that have numbers only.
I dont have any virtual keyboard application. Could you please help me out to trace the application.
And i would like to know, which will be better, a custom widget or a input panel.??
Looking forward for your reply...
Regards
vinithr
Kindly also google little...
A little search would have given you these -
http://qt-project.org/doc/qt-4.8/tools-inputpanel.html
http://labs.qt.nokia.com/2009/08/31/...ual-keyboards/
vinithr (11th June 2012)
Look at this link
vinithr (11th June 2012)
I've attached my code for a virtual keyboard (see InputDevice.zip)
at the moment it only works for qlineedit but it is easy to change it for other inputs
password input is supported
sorry documentation is missing and the chaos in the code
this is how to use it:
* make an instance of the input device in your main after doing this it is working (InputDevice *inputdevice = new InputDevice; //start the keyboard)
* add a custom property to a QLineEdit and call it keyboard and set it to true (this enables the keyboard for the lineedit)
* optionally add a custom property inputType set it to REAL or INT for the numpad type any other value will be handled as string and starts the keyboard
i hope it will help u create your own keyboard or use it as is
vinithr (10th June 2012)
OK create one keyboard and create an instance of it in your class and use it. Or simple is that create one lineedit with keyboard having pushbuttons. and connect all the push button to your lineEdit. If you want to use your keyboard in differents gui then you have to create a different class for keyboard. if you want some help in keyboard tutorial then you're welcome to query.
evandropadrao (10th May 2016)
Thanks for your help..
I've changed the keyboard to now also be able to use QValidator instead of the custom property inputType
if you add a QDoubleValidator or QIntValidator to your lineedit it shows the numberic editor and also checks the value
download the new version InputDeviceV2.zip
Last edited by StrikeByte; 11th June 2012 at 10:09.
vinithr (11th June 2012)
I have a doubt in "If you want to use your keyboard in differents gui then you have to create a different class for keyboard": for each GUI I need create another "InputDevice" or create another "keyboard"? In this case, do I need to create another "installEventFilter". I create a tested app that in mainwindow I have some qlineedit that is working fine and a button to open a new QDialog. In this dialog, I have also some qlineedit. When I select this object, the keyboard is showed but no key pressed is accepted (I believe that slot-signal is defined to mainwindow). Could you help me ?
Last edited by evandropadrao; 27th April 2016 at 02:51.
Hello, StrikeByte.
Great thanks for you project. I used many time your keyboard for my Qt4 application. It worked nice.
But now I want to migrate my app to Qt5 and, of course, I planned to use your virtual keyboard adopted to Qt5.
But, sorry, I had epic fail((
My environment: embedded device, Qt5.4.2, X11.
I don't understand how to load plugin to app.
I used QT_DEBUG_PLUGINS=1 and I saw that plugin was found, but it's not loaded.
QFactoryLoader::QFactoryLoader() looking at "/usr/local/qt/qt542-ti-qml/plugins/platforminputcontexts/libVirtualInput.so"
Found metadata in lib /usr/local/qt/qt542-ti-qml/plugins/platforminputcontexts/libVirtualInput.so, metadata=
{
"IID": "org.qt-project.Qt.QPlatformInputContextFactoryInterface",
"MetaData": {
"Keys": [
"virtualinput"
]
},
"className": "VIPlatformInputContextPlugin",
"debug": false,
"version": 328706
}
Got keys from plugin meta data ("virtualinput")
I tried to add DEFINES += VIRTUALINPUT_LIBRARY to .pro file.
I tried to add VIPlatformInputContextPlugin virtualKeyboard; or VIInputContext virtualKeyboard; to my main.cpp.
I saw that similar questions were above. Please give us simple project for Qt5 with your keyboard.
Thanks.
Last edited by titan83; 30th April 2016 at 11:34.
Ok. I answer to my question myself.
First: I don't know how to change input context plugins order. So I delete all other pluging from my plugins/platforminputcontexts folder. Virtual keybord plugin starts to load.
Second: I should to work under X11, not with EGLFS or LinuxFB, unfortunately( And when I pressed on QLineEdit I see nothing. But from debug output I saw that show() method is called, hide() is too. So I add | Qt::X11BypassWindowManagerHint to numpad and keyboard constructors. Also I add call raise() method after show() in both files.
Now virtual keyboard is working.
Hope it will useful.
StrikeByte thanks for share your work. Could you provide application example for use provided inputDevice. Thanks in advance
Hi Experts,
Do you have any idea about how to add virtual keyboard support in QT browser (Example Fancy browser)?
If i click the loaded webpage text input field (example "google search" input box in the google web site) virtual keyboard should be pop up.
Any idea?
if you have any code means please share it here...
Thanks in advance,
Veera
here is a new version, this only contains some fixes InputDeviceV3.zip
Howto use:
main.cpp
Qt Code:
#include <QApplication> #include "inputdevice.h" int main(int argc, char *argv[]) { QApplicationa(argc, argv); InputDevice inputdevice; //here the code for forms or something else return a.exec(); }To copy to clipboard, switch view to plain text mode
code for enabling keyboard on a lineedit
Qt Code:
aLineEdit->setProperty("keyboard",true); //enable the keyboard (this is a custom property) aLineEdit->setValidator(QIntValidator(0,500)); //add a int validator min value 0 max value 500. This will force the numpad to show, you can also use a QDoubleValidator aTextLineEdit->setProperty("keyboard",true); // enable the keyboard. when there is no validator set the keyboard will show //aTextLineEdit->setProperty("maxLength",25); //this can be used to limit the length of the string //it is also possible to set the properties in QT designerTo copy to clipboard, switch view to plain text mode
Hello,
Thanks for your example, it is very useful. In Qt5 does not work because does not finds #include <QInputContext>
Do you have a idea?
Thanks
Hello,
When I'm trying to include your code as per the previous instructions I get the following errors:
undefined reference to `Numpad::activate(QVariant, QValidator const*)'
undefined reference to `Numpad::setEchoMode(QLineEdit::EchoMode)'
undefined reference to `Keyboard::activate(QVariant, int, bool)'
undefined reference to `Keyboard::setValidator(QValidator const*)'
Could you please point out to me what the problem is?
Best regards
Bookmarks