Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to use Qt Virtualkeyboard in my QML program?



  • Is there is any tutorial or step by step method! I am using Qt5.10 on Linux, and I need the keyboard for raspberry application!



  • Till this moment I coudn't find a helpful tips, I had to create my own keypad to let the user add numbers as temporary solution,

    but still I hope if any one can help !


  • Moderators

    @MAthias_Va
    may be a stupid question, but did you look at the docs yet?!
    Also you should tell what you've done so far or what happens in your application. Otherwise i can only tell what you could also look up in the docs.



  • Yes @raven-worx I went through this document several times, but it is pretty tough to apply for me as a beginner,

    What I could do from the doc; I was able just to run the built in Qt example!

    What I need to do: I need a numeric Keypad pops up when the user try to enter text!

    But I understand I need to build the Keyboard in my application, I can see the Build Instructions , but I don't know where to write it and so on!


  • Moderators

    @MAthias_Va
    k here is a quick overview:

    1. no need to compile anything (unless you know why). The QtVirtualKeyboard module can be downloaded from the installer
    2. add qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); at the very beginning of your main()
    3. Place a InputPanel QML element where you want the keyboard to appear
    4. In QML use a TextField, TextInput, etc. element and set it's inputMethodHints property to Qt.ImhDigitsOnly


  • @raven-worx

    Woow this is so easy, Once I added line 2 in the very beginning of main, I can see the Keyboard, but the weird thing is it launched in my program on start up-without calling it-, and transparent as you see in the picture below;



  • I see I should add

    disable-desktop|android-embedded|!isEmpty(CROSS_COMPILE)|qnx {
       DEFINES += MAIN_QML=\\\"basic-b2qt.qml\\\"
    } else {
       DEFINES += MAIN_QML=\\\"Basic.qml\\\"
    }
    

    in my .pro file! should it be at the end of page! is it matter here! I need it for raspberry, should I delete (disable-desktop) or keep it!



  • @raven-worx , finally I get it, I forget to do step 3



  • @MAthias_Va if your issue is solved, please mark your post as such! Thanks.


Log in to reply