5

I try to integrate the QtVirtualKeyboard into a prototype, but I fail. It is the first time I work with multiple projects or where I have to include non-basic-stuff in QML/QMake-Project.

I got the code from the git-repository and were successfully running the examples. But now I am puzzled on how to integrate it into my own project.

My project structure is as follows

Proto (dir)
 +- Proto.pro
 +- main.cpp
 +- ...
 +---QML (dir)                     <--- QML-Files
 |    +-main.qml
 |    +---CustomControls (dir)
 |    +---...
 +---CPP (dir)                     <--- C++-Files and Headers
 +---RES                           <--- Icons and stuff

Now I thought I might just add the src-project from the virtual keyboard to the root-folder (Proto), and add something like:

SUBDIR += src/src.pro

to the Proto.pro-file
=> Yes, I can do that, but there is no merrit in it.

So what do I need to do, to actually use it? It must be really easy, for I can't find any question regarding it anywhere on google, youtube or SO.

EDIT => I still fail. This is my story:

I tried the deployment-method, followed the instructions here.
As I'd prefer to have the keyboard within the application, I did the following:

  1. I added the make install-stept
  2. I passed qmake an additional argument "CONFIG+=disable-desktop

It seemed to work. Got new files in the mentioned directories:

  • C:\Qt\Qt5.7.0\5.7\mingw53_32\qml\QtQuick\VirtualKeyboard
  • C:\Qt\Qt5.7.0\5.7\mingw53_32\qml\QtQuick\Virtualkeyboard\Styles
  • C:\Qt\Qt5.7.0\5.7\mingw53_32\plugins\platforminputcontexts\

Now in my project, I added the line

QT_IM_MODULE=qtvirtualkeyboard myapp

And tried to import it in my main.qml

import QtQuick.VirtualKeyboard 2.0 // (also tried it with 2.1)

I got the error:

[path]/main.qml:10 module "QtQuick.VirtualKeyboard" is not installed

And that concludes my story sofar. Any suggestions where I failed?

  • I think you have to include `qtvirtualkeyboard.pro` into your main .pro file and so all will be done automatically – folibis Mar 03 '17 at 10:59
  • But I don't know, how to. – derM - not here for BOT dreams Mar 03 '17 at 11:08
  • Copy and paste the content of `qtvirtualkeyboard.pro` into your `main.pro`. – Vedanshu Mar 03 '17 at 12:40
  • 1
    AFAIR you can have multiple `.pri` files inside a `pro`, confirmed by Sir. lpapp himself [here](http://stackoverflow.com/a/23845651). And by renaming a `pro` to `pri` it can be included inside your `pro`. What I do not get is why you should rebuild the keyboard module? Isn't it part of the open offer now? In any case I would compile and deploy the module. That sounds easier. – BaCaRoZzo Mar 03 '17 at 12:49
  • I need to rebuild the keyboard module, as - afaik - there is no pre-built module (at least for Win). I tried it with the "*compile and deploy*" but as I failed (could not import the module after) I thought maybe I got it all wrong, and tried to include it directly into my project. Probably wrong approach though :D – derM - not here for BOT dreams Mar 06 '17 at 12:32

2 Answers2

13

Ok, I finally succeeded. Though it is indeed very close to the documentation I don't think the documentation is easily understood. Therefor I will post this step-by-step-guid, where I will clear my own misconceptions.

  1. Download the sourcecode from the git-repository
  2. Open the project qtvirtualkeyboard.pro with the QtCreator, and run it with the configuration release
    It will create some directories and files in your Qt-installation dir. You do not need to add anything in your project directory. Once done and your good for all projects to come.
  3. Make sure, you set the QT_IM_MODULE environment variable to include qtvirtualkeyboard. My mistake was, to assume (I don't know why) this might be done in the projects .pro-file. This seems to be wrong. The C++-method seems safe:
    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));

  4. If you want to have the keyboard within your application, add
    CONFIG += disable-desktop to your projects .pro-file

  5. Have fun!

  • I cloned the repo, compiled it release build, ran make install in the build directory, checked that files `Qt/5.10.1/android_armv7/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.so` and `Qt/5.10.1/android_armv7/qml/QtQuick/VirtualKeyboard/Styles/libqtvirtualkeyboardstylesplugin.so` are added, `QT_IM_MODULE` is set (it works for desktop version) but it still doesn't work for android: `module "QtQuick.VirtualKeyboard" is not installed` do you have any hints for me? – Sassan Apr 16 '18 at 08:57
  • Sorry, I have no experience what so ever with android. – derM - not here for BOT dreams Apr 16 '18 at 09:08
3

If you select the Qt Virtual Keyboard component under a particular Qt version, you should get the prebuilt binaries:

Maintenance Tool

The Qt Enterprise Add-ons component has a virtual keyboard sub-component (?) which might only give you the sources.. not sure.

If you really need to have the module in your project's Git repo, it might be easier to just add it as a submodule, and reference that in a "3rdparty" SUBDIRS sub-project.

Mitch
  • 23,716
  • 9
  • 83
  • 122
  • It's not necessary for me to have it in my project. I just need to be able to use it and failed for the time beeing with the documentation. Now I managed to clear my misconceptions, about how to integrate it. That tool (I assume it is the from the *Install/Uninstall-Tool*) does not work, as I can't set the proxies right :-( – derM - not here for BOT dreams Mar 06 '17 at 13:26
  • 1
    Can you please open a bug report about what could be improved in the documentation? What was unclear, etc. That way we can improve it. – Mitch Mar 06 '17 at 13:33