Page 1 of 2 12 LastLast
Results 1 to 20 of 36

Thread: virtual keyboard in QT Application

  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,464
    Thanked 272 Times in 267 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 11:09.

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

    vinithr (11th June 2012)

  19. #10
    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

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


  21. #11
    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

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


  23. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,363
    Thanks
    3
    Thanked 5,012 Times in 4,791 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.


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


  25. #13
    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 

  26. #14
    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

  27. #15
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: virtual keyboard in QT Application

    In Qt5 this is handled as part of the platform integration plugin (QPA).

    qtbase/src/plugins/platforms

    Cheers,
    _

  28. #16
    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

  29. #17
    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 can refer to this thread.

    Hope it helps

  30. #18
    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

    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

  31. #19
    Join Date
    Mar 2015
    Posts
    2
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Re: virtual keyboard in QT Application

    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.
    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;
    ^
    This was running qmake && make in the project dir.
    What am I doing wrong? Do you need any more information?

    EDIT: running on OSX 10.10.2

  32. #20
    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 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.

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, 09: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, 12:58
  3. Virtual Keyboard?
    By augusbas in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 14th July 2009, 09:55
  4. Virtual Keyboard
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 3rd September 2007, 20:59
  5. virtual keyboard
    By sar_van81 in forum Qt Programming
    Replies: 5
    Last Post: 22nd December 2006, 14: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.