Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running example on Windows #1

Open
erakis opened this issue Jun 4, 2015 · 22 comments
Open

Running example on Windows #1

erakis opened this issue Jun 4, 2015 · 22 comments

Comments

@erakis
Copy link

erakis commented Jun 4, 2015

Hi,

I'm really interested to use your keyboard on Linux and Windows. First thank you so much to share your work.

But I'm not able to get it work under Windows first.

1 - First I build the src project. This produced an VirtualKeyboard.dll.
2 - I copy those file to this folders C:\Qt\5.4\msvc2013\plugins\platforminputcontexts\VirtualKeyboard
- FontAwesome.otf
- InputPanel.qml
- KeyButton.qml
- KeyPopup.qml
- qmldir
- VirtualKeyboard.dll
- VirtualKeyboard.pdb
3 - Now I open the example project and run it.

I'm always getting error about the keyboard module not found.

I have also tried putting all those file inside this directory \examples\qmlapp\VirtualKeyboard. But same problem :(

What is exactly the correct structure to use this plugin ?

Best regards,

@smelmo
Copy link

smelmo commented Aug 6, 2015

Have you figured this out yet? I'm having the same issue with getting this to work.

Thank you,

@erakis
Copy link
Author

erakis commented Aug 9, 2015

Sorry for the late.

I got a response from another forum but it is in french. Hope you will find answer to your question.

http://www.developpez.net/forums/d1524815/c-cpp/bibliotheques/qt/qt-quick/installation-qtfreevirtualkeyboard/

@erakis erakis closed this as completed Aug 9, 2015
@erakis erakis reopened this Aug 9, 2015
@smelmo
Copy link

smelmo commented Aug 10, 2015

Thank you, I was able to get it to run following the final advice by Amnell, but I run into the error that "InputEngine is not defined" every time I press a key. I don't suppose you ran into that error too?

@erakis
Copy link
Author

erakis commented Aug 10, 2015

No I did not :( The only problem I had was syntax error by QTCreator that complains about the not finding some import but while running the executable it was OK. Amnell has notice it too.

@jacbop
Copy link

jacbop commented Sep 2, 2015

@smelmo I also get "InputEngine is not defined". I had to edit the code to "import QtQuick.VirtualKeyboard 1.0" rather than "import VirtualKeyboard 1.0" everywhere. The keyboard now renders on the screen and I can click buttons, but I get the same error message as you.

It seems like this is a type from the enterprise version.
http://doc.qt.io/QtVirtualKeyboard/qml-qtquick-enterprise-virtualkeyboard-inputengine.html

I hope I am mistaken, as was hoping to find a starting point to use without getting an enterprise license.

@purell since you did not see this error, and presumeable were able to receive keyboard input to your app, can you please confirm which version of QtCreator you are using?

@githubuser0xFFFF can you please confirm whether this project requires the InputEngine QML type from the enterprise version to function? I appreciate you sharing the work.

Thanks.

@erakis
Copy link
Author

erakis commented Sep 2, 2015

I'm using QTCreator 3.4.2.

You do not need the enterprise module "QtQuick.VirtualKeyboard 1.0". Take a look in the file VirtualKeyboadInputContext.cpp, the InputEngine is declared here and implemented in DeclarativeInputEngine.h/cpp :

VirtualKeyboardInputContext::VirtualKeyboardInputContext() :
QPlatformInputContext(), d(new VirtualKeyboardInputContextPrivate)
{
...
// Watch here, you have the InputEngine qml singleton type that is
// declared for DeclarativeInputEngine
qmlRegisterSingletonType("VirtualKeyboard", 1, 0,
"InputEngine", inputEngineProvider);
...
}

It's too bad, I had a complete example that works with this keyboard, but I deleted because I built by myself a new virtual keyboard and it works differently.

I took a look in my backup, but it is not there :(

@jacbop
Copy link

jacbop commented Sep 2, 2015

Thank you, I see what you mean regarding the InputEngine being declared as a singleton. But I must be doing something incorrectly or missing something as that singleton value is not available to my Qml at runtime.

Here is what I have done so far. Perhaps someone can tell me what I am doing wrong. I will happily update and provide some clear instructions for those who may have similar problems once I have it working..

From a clean clone I do the following:

cd src

Apply these changes (the make install puts the Qml under the QtQuick folder, so the out of the box import statements did not work for me):

diff --git a/src/InputPanel.qml b/src/InputPanel.qml
-import VirtualKeyboard 1.0
+import QtQuick.VirtualKeyboard 1.0

diff --git a/src/KeyButton.qml b/src/KeyButton.qml
-import VirtualKeyboard 1.0
+import QtQuick.VirtualKeyboard 1.0

qmake
make install

This installed the shared lib to $$[QT_INSTALL_PLUGINS]/platforminputcontexts and the Qml files to $$[QT_INSTALL_QML]/QtQuick/VirtualKeyboard

Now create a simple QtQuick project (I'm using Qt 5.5)

Here is my .pro

TEMPLATE = app

QT += qml quick widgets

SOURCES += main.cpp

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Default rules for deployment.
include(deployment.pri)

Here is my main.cpp

#include <QQuickView>
#include <QGuiApplication>
#include <QQmlEngine>

int main(int argc, char *argv[])
{
    qputenv("QT_IM_MODULE", QByteArray("VirtualKeyboard"));

    QGuiApplication app(argc, argv);
    app.setObjectName("QGuiApplication");

    QQuickView view;
    view.setSource(QString("qrc:/main.qml"));
    view.setResizeMode(QQuickView::SizeRootObjectToView);
    view.setObjectName("QQuickView");
    view.setWidth(640);
    view.setHeight(480);
    view.engine()->setObjectName("QQuickEngine");
    view.engine()->addImportPath(qApp->applicationDirPath());

    view.show();

    return app.exec();
}

I tried all sorts of variations when setting QT_IM_MODULE (e.g. qtvirtualkeyboard, virtualkeyboard, VirtualKeyboard)

And my main.qml

import QtQuick 2.4
import QtQuick.VirtualKeyboard 1.0
import QtQuick.Controls 1.2
import QtQuick.Window 2.0

Item {
    id: appContainer
    anchors.fill: parent
    TextField {
        id: inputField
        width: parent.width
    }

    InputPanel {
        id: inputPanel
        z: 99
        width: parent.width
        anchors.centerIn: parent
        states: State {
            name: "visible"
            when: Qt.inputMethod.visible
            PropertyChanges {
                target: inputPanel
                y: appContainer.height - inputPanel.height
            }
        }
        transitions: Transition {
            from: ""
            to: "visible"
            reversible: true
            ParallelAnimation {
                NumberAnimation {
                    properties: "y"
                    duration: 150
                    easing.type: Easing.InOutQuad
                }
            }
        }
    }
}

Running this example, I see the virtual keyboard but when I click on buttons I get the following errors:

file:///Users/tom/Qt/5.5/clang_64/qml/QtQuick/VirtualKeyboard/InputPanel.qml:16: ReferenceError: InputEngine is not defined
qml: showKeyPopup
qml: popup: inputPanel
qml: keybutton.text: q
qml: Popup position left: 7
qml: onReleased - functionKey = false
file:///Users/tom/Qt/5.5/clang_64/qml/QtQuick/VirtualKeyboard/KeyButton.qml:164: ReferenceError: InputEngine is not defined

Am I doing something obviously wrong? If it was working for you, do you see something that I am missing or have incorrect?

Thanks,
Tom

@jacbop
Copy link

jacbop commented Sep 2, 2015

screen shot 2015-09-02 at 2 02 37 pm

This screenshot shows what I am seeing: a keyboard that I can interact with, but the InputEngine error each time I click on a key.

@githubuser0xFFFF
Copy link
Owner

I just cloned the project from github and did the following steps to run the example:

  1. cd into src folder
  2. qmake
  3. make install
  4. cd into examples/qmlapp
  5. qmake
  6. make
  7. run virtualkeyboardqmldemo.exe

I'm using Qt 5.4.1 on Windows with MinGW

@ratwix
Copy link

ratwix commented Sep 4, 2015

Hello. Thanks for your reply.

I've just try your steps. It's work on QT 5.4.1, but didn't on QT 5.5 (module didn't load)

Maybe related to this issue ? https://bugreports.qt.io/browse/QTBUG-47255

Any advices ?

EDIT1: build is not the problem, even build with QT 5.5, when path is set to QT 5.4.1 (with make install done on QT 5.4.1) it works

EDIT2: By replacing "import VirtualKeyboard 1.0" by "import QtQuick.VirtualKeyboard 1.0", application launch with QT 5.5, but Keyboard did not show. Error : file:///D:/Qt/5.5/mingw492_32/qml/QtQuick/VirtualKeyboard/InputPanel.qml:49: ReferenceError: InputEngine is not defined

@githubuser0xFFFF
Copy link
Owner

This is strange. That means, something has changed from Qt 5.4.1 to Qt 5.5. If have not installed Qt 5.5 and can not fix this issue yet - sorry

@alepez
Copy link

alepez commented Oct 9, 2015

Hi guys, I've tested this with Qt 5.5 and 5.2.0. If you replace "import VirtualKeyboard 1.0" with "import QtQuick.VirtualKeyboard 1.0" you must be sure to put qml files in the right directory relative to import path "QtQuick/VirtualKeyboard" and modifiy a line in VirtualKeyboardInputContext constructor, where it register the type:

        qmlRegisterSingletonType<DeclarativeInputEngine>("QtQuick.VirtualKeyboard", 1, 0, "InputEngine", inputEngineProvider);

As you can see, I've added "QtQuick" in the uri. With this changes it works fine. Any change you make to uri or version, you have to be sure to change:

  • import statement in qml files
  • qmlRegisterSingletonType in VirtualKeyboardInputContext constructor

QT_IM_MODULE environment variable must have the same value found in VirtualKeyboardInputContextPlugin::create

    qDebug() << "VirtualKeyboardInputContextPlugin::create: " << system;
    if (system.compare(system, QStringLiteral("qtvirtualkeyboard"), Qt::CaseInsensitive) == 0)
    {
        return VirtualKeyboardInputContext::instance();
    }
    return 0;

Here the value is "qtvirtualkeyboard". You can change it, but QT_IM_MODULE must match it.

When the app start up you should see a message in the log: VirtualKeyboardInputContextPlugin::create: "qtvirtualkeyboard"

If this doesn't happen, maybe the app cannot load the InputMethod plugin. Make sure the library is in the right path. In my system (linux) I figured out the right path with the command strace.

strace ./bin/MyApp 2>&1 | grep stat | grep "\".*platforminputcontexts" -o

This is my output:

/opt/Qt/5.2.0/gcc_64/plugins/platforminputcontexts
/home/pez/workspace/my-project/dist/linux-desktop-x86_64/bin/platforminputcontexts
/usr/lib64/kde4/plugins/platforminputcontexts

Every match of platforminputcontexts is a directory where the app is looking for the virtualkeyboard plugin. The first one is my QML2_IMPORT_PATH, the second is the directory where the executable is and the third is a system directory (my Desktop is KDE, based on Qt).

So, if you don't get a VirtualKeyboardInputContextPlugin::create: "qtvirtualkeyboard" message in your log, try creating a platforminputcontexts directory next to the executable an put here the virtualkeyboard plugin (the shared library built, in linux it is libVirtualKeyboard.so). You can also rename it to whatever you want, even change the extension, Qt plugin system loads every file it find in platforminputcontexts directory.

@githubuser0xFFFF
Copy link
Owner

Hi Alessandro, thak you for sharing your valuable tips. I will test it as soon as I have Qt 5.5 installed.

@10-21
Copy link

10-21 commented Nov 2, 2015

Hi,
I've tested with Qt 5.5.1. There they have changed the IID of the plugin, so it can not be loaded. If you enable the plugin debugging (set QT_DEBUG_PLUGINS to 1) you see that Qt does not found any keys in the plugin.
You have to modify the file VirtualKeyboardInputContextPlugin.h and change

Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface" FILE "VirtualKeyboardInputContextPlugin.json")

to

Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface.5.1" FILE "VirtualKeyboardInputContextPlugin.json")

then the plugin will be successful loaded.
But the plugin doesn't wok either. I have put some debug messages in my plugin and it seems the plugin get no notification if the focus of an item change. VirtualKeyboardInputContext::setFocusObject is called once on startup of my app but not if i click in a text field.

At the moment i have no time to search further for the problem but maybe my previous research helped.

@gbosiger
Copy link
Contributor

gbosiger commented Dec 1, 2015

Hi guys,

I found the solution to this problem that worked for me: fcitx/fcitx-qt5#6

Try to change:

Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformInputContextFactoryInterface" FILE "VirtualKeyboardInputContextPlugin.json")

to

Q_PLUGIN_METADATA(IID QPlatformInputContextFactoryInterface_iid FILE "VirtualKeyboardInputContextPlugin.json")

I've also moved plugin to app's directory, and it also works if platforminputcontexts directory is created as alessandro-pezzato said.

I've tested this with Qt 5.3, 5.4.2, 5.5

@githubuser0xFFFF
Copy link
Owner

Great, thank you.

Could you please create a pull request to merge these changes?

@gbosiger
Copy link
Contributor

gbosiger commented Dec 1, 2015

Done.

@githubuser0xFFFF
Copy link
Owner

I merged your request - thank you.

@vinifr
Copy link
Contributor

vinifr commented Jan 24, 2016

Hi, I cross compiled QT 5.5.1 and QtFreeVirtualKeyboard for Raspberry PI 2.

I copied manually the .qml files for /usr/local/qt5pi/qml/QtQuick/VirtualKeyboard and libVirtualKeyboard.so for /usr/local/qt5pi/plugins/platforminputcontexts/
But when I try to execute, return:

./virtualkeyboardqmldemo
VirtualKeyboardInputContextPlugin::create: "qtvirtualkeyboard"
�[9;0]Unable to query physical screen size, defaulting to 100 dpi.
To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
file:///home/pi/projs/QtFreeVirtualKeyboard/examples/qmlapp/MainContainer.qml:20:1: module "QtQuick.VirtualKeyboard" is not installed
import QtQuick.VirtualKeyboard 1.0
^
VirtualKeyboardInputContext::setFocusObject

@smratijohri
Copy link

hi,
i want to use your virtual keyboard for qnx platform, after building it want to deploy it on our hardware.
i build your project on QtCreator and it is building successfully.
but when i deploy this on my hardware, it doesnt show up. Rather a blank white screen comesup and nothing more than than. Can you please help
Steps i followed to compile and deploy:
1.QtFreeVirtualKeyboard-master\src -> open virtualkeyboard.pro and build it
2.QtFreeVirtualKeyboard-master\examples\qmlapp -> open qmlappdemo.pro and build it
3.Deployed the executable on my harware using qnxmomentics.
4. tried to run the executable using teraterm. but a blank white screen comesup.

i am completely new to QT or rather even QNX. Please guide me on the same. and sorry if have missed something.

thanks

@CikaLaza
Copy link

Hi,
I'm also having problem with deployment of this plugin.
Plugin usage stated in cpp like "qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"))".

If I use "import QtQuick.VirtualKeyboard 1.0" in InputPanel.qml,
then there is "InputEngine is not defined" problem, as described above.

Using "import VirtualKeyboard 1.0" fixed the problem and I can run application.
But, the problem is when I try to use my app from "installation package" with:

  • plugins/platforminputcontexts/libVirtualKeyboard.so, exported as LD_LIBRARY_PATH
  • qml/QtQuick/VirtualKeyboard/InputPanel.qml (and others), exported as QML_IMPORT_PATH

qrc:///qmlplayer2.qml:574 Type InputPanel unavailable
...qml/QtQuick/VirtualKeyboard/InputPanel.qml:3 module "VirtualKeyboard" is not installed

If the suggestion is to import VirtualKeyboard without QtQuick prefix, should we also change installation path for qml files, should they be copied to qml/VirtualKeyboard instead of qml/QtQuick/VirtualKeyboard (as defined in Makefile, rule install_deployment)?

@fanjiafei
Copy link

Hi,
I had successfully run this virtualKeyboard,and met some problem same as above.So,I'm writing my solution with the hope that this will help you.
QtFreeVirtualKeyboard Nov 6, 2016 version
Qt Version 5.4.0
Ubuntu Version 16.04

firstly I buildout successfully
then try to execute virtualkeyboardqmldemo and it returned

MainContainer.qml:20:1: module "QtQuick.FreeVirtualKeyboard" is not installed
import QtQuick.FreeVirtualKeyboard 1.0

open virtualkeyboard.pro,you will see

deployment.path = $$[QT_INSTALL_QML]/QtQuick/FreeVirtualKeyboard
target.path = $$[QT_INSTALL_PLUGINS]/platforminputcontexts

if you add this code
message($$deployment.path)
message($$target.path)

and you will see this output:(this is my output:)

Project MESSAGE: /home/fan/Qt5.4.0/5.4/gcc/qml/QtQuick/FreeVirtualKeyboard
Project MESSAGE: /home/fan/Qt5.4.0/5.4/gcc/plugins/platforminputcontexts

so ,you known two folder.
yes,we need to copy some files to those folder_(I recomend 'ln' instead of 'copy‘’)_
(/media/fan/DiskA/Workspace/QtFreeVirtualKeyboard-master is my PC path,you should replace this with your QtFreeVirtualKeyboard-master path )

➜  cd /home/fan/Qt5.4.0/5.4/gcc/qml/QtQuick 
➜  mkdir FreeVirtualKeyboard
➜  cd FreeVirtualKeyboard 
➜  ln -s /media/fan/DiskA/Workspace/QtFreeVirtualKeyboard-master/src/InputPanel.qml InputPanel.qml 
➜  ln -s /media/fan/DiskA/Workspace/QtFreeVirtualKeyboard-master/src/KeyButton.qml KeyButton.qml
➜  ln -s /media/fan/DiskA/Workspace/QtFreeVirtualKeyboard-master/src/KeyModel.qml KeyModel.qml 
➜  ln -s /media/fan/DiskA/Workspace/QtFreeVirtualKeyboard-master/src/KeyPopup.qml KeyPopup.qml
➜  ln -s /media/fan/DiskA/Workspace/QtFreeVirtualKeyboard-master/src/qmldir qmldir 
➜  cd /home/fan/Qt5.4.0/5.4/gcc/plugins/platforminputcontexts
➜  ln -s /media/fan/DiskA/Workspace/QtFreeVirtualKeyboard-master/build-virtualkeyboard-Desktop_Qt_5_4_0_GCC_32bit-Debug/libfreevirtualkeyboardplugin.so libfreevirtualkeyboardplugin.so

at this time you can retry execute virtualkeyboardqmldemo
vitual keyboard will show up

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests