Results 1 to 20 of 36

Thread: virtual keyboard in QT Application

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2012
    Posts
    49
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default virtual keyboard in QT Application

    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

  2. The following user says thank you to vinithr for this useful post:


  3. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    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.

  4. The following 2 users say thank you to aamer4yu for this useful post:

    vinithr (11th June 2012)

  5. #3
    Join Date
    Apr 2012
    Posts
    49
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: virtual keyboard in QT Application

    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

  6. The following user says thank you to vinithr for this useful post:


  7. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    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/

  8. The following 2 users say thank you to aamer4yu for this useful post:

    vinithr (11th June 2012)

  9. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    Look at this link

  10. The following 2 users say thank you to Lesiok for this useful post:

    vinithr (11th June 2012)

  11. #6
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    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

  12. The following 2 users say thank you to StrikeByte for this useful post:

    vinithr (10th June 2012)

  13. #7
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    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.

  14. The following 2 users say thank you to sonulohani for this useful post:

    evandropadrao (10th May 2016)

  15. #8
    Join Date
    Apr 2012
    Posts
    49
    Thanks
    14
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: virtual keyboard in QT Application

    Thanks for your help..

  16. The following user says thank you to vinithr for this useful post:


  17. #9
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    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.

  18. The following 2 users say thank you to StrikeByte for this useful post:

    vinithr (11th June 2012)

  19. #10
    Join Date
    Sep 2015
    Posts
    1
    Thanks
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: virtual keyboard in QT Application

    Quote Originally Posted by sonulohani View Post
    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.
    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.

  20. #11
    Join Date
    May 2015
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: virtual keyboard in QT Application

    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.

  21. #12
    Join Date
    May 2015
    Posts
    2
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: virtual keyboard in QT Application

    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.

  22. #13
    Join Date
    Jul 2009
    Posts
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    StrikeByte thanks for share your work. Could you provide application example for use provided inputDevice. Thanks in advance

  23. The following user says thank you to newzen for this useful post:


  24. #14
    Join Date
    May 2013
    Posts
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Maemo/MeeGo

    Default Re: virtual keyboard in QT Application

    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

  25. The following user says thank you to Veerapandian for this useful post:


  26. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: virtual keyboard in QT Application

    Implement an input context plugin.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  27. The following user says thank you to wysota for this useful post:


  28. #16
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    here is a new version, this only contains some fixes InputDeviceV3.zip

    Howto use:
    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include "inputdevice.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplicationa(argc, argv);
    7. InputDevice inputdevice;
    8.  
    9. //here the code for forms or something else
    10.  
    11. return a.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    code for enabling keyboard on a lineedit
    Qt Code:
    1. aLineEdit->setProperty("keyboard",true); //enable the keyboard (this is a custom property)
    2. 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
    3.  
    4. aTextLineEdit->setProperty("keyboard",true); // enable the keyboard. when there is no validator set the keyboard will show
    5. //aTextLineEdit->setProperty("maxLength",25); //this can be used to limit the length of the string
    6.  
    7. //it is also possible to set the properties in QT designer
    To copy to clipboard, switch view to plain text mode 

  29. #17
    Join Date
    Mar 2014
    Posts
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: virtual keyboard in QT Application

    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

  30. #18
    Join Date
    Jul 2014
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: virtual keyboard in QT Application

    Quote Originally Posted by StrikeByte View Post
    here is a new version, this only contains some fixes InputDeviceV3.zip

    Howto use:
    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include "inputdevice.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplicationa(argc, argv);
    7. InputDevice inputdevice;
    8.  
    9. //here the code for forms or something else
    10.  
    11. return a.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    code for enabling keyboard on a lineedit
    Qt Code:
    1. aLineEdit->setProperty("keyboard",true); //enable the keyboard (this is a custom property)
    2. 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
    3.  
    4. aTextLineEdit->setProperty("keyboard",true); // enable the keyboard. when there is no validator set the keyboard will show
    5. //aTextLineEdit->setProperty("maxLength",25); //this can be used to limit the length of the string
    6.  
    7. //it is also possible to set the properties in QT designer
    To copy to clipboard, switch view to plain text mode 
    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

Similar Threads

  1. virtual keyboard application : errror during cross-compile
    By sanjeet in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 31st August 2011, 08:48
  2. How to get the virtual keyboard?
    By ramesh.bs in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 2nd June 2010, 11:58
  3. Virtual Keyboard?
    By augusbas in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 14th July 2009, 08:55
  4. Virtual Keyboard
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 3rd September 2007, 19:59
  5. virtual keyboard
    By sar_van81 in forum Qt Programming
    Replies: 5
    Last Post: 22nd December 2006, 13:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.