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 11:09.
vinithr (11th June 2012)
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
In Qt5 this is handled as part of the platform integration plugin (QPA).
qtbase/src/plugins/platforms
Cheers,
_
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
You can refer to this thread.
Hope it helps
It's a while ago that I made InputDeviceV3.zip, but didn't have a need to build a new one up until now,
now I needed a virtual input for Qt5.3 so I made the InputDevice working again.
I didn't do any major changes (only the name), it still only works for QLineEdits
Here is the download:
VirtualInput.zip
How to use:
- Build the library
- copy the library to platforminputcontexts in your application or to plugins/platforminputcontexts in your QtDir
- Add a custom property named "keyboard" (without the quotes) of the type bool to the QLineEdit and set it to enabled
- For text you can set the maxLength property
- For values you can add a QIntValidator to the QLineEdit
Hi, thanks for the update.
I'm pretty new to Qt (and to C++) and I'm having trouble using your project. Running Qt-Creator 3.3.0 and Qt5.4.
I can open your project, but compiling it yields errors.
This was running qmake && make in the project dir.numpad.cpp:166:18: error: taking the address of a temporary object of type 'QVariant' [-Waddress-of-temporary]
emit dataSet(&QVariant(ui->edValue->text()));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
numpad.cpp:189:33: error: non-const lvalue reference to type 'QString' cannot bind to a temporary of type 'QString'
if (validator->validate(ui->edValue->text(),pos) == QValidator::Acceptable)
^~~~~~~~~~~~~~~~~~~
/Users/srm/Development/Qt/5.4/clang_64/lib/QtGui.framework/Headers/qvalidator.h:67:37: note: passing argument to parameter here
virtual State validate(QString &, int &) const = 0;
^
What am I doing wrong? Do you need any more information?
EDIT: running on OSX 10.10.2
I made the project on a windows machine and a visual studio compiler. It looks like the compiler you are using won't allow temp variables in function calls
I don't have a mac to try it on.
Mabe you can find more when googling the error description (QString' cannot bind to a temporary of type 'QString) or start a thread in the newbe section of the forum.
Bookmarks