I have tried for a couple of days to setup Virtual Keyboards in a Linux application. My application contains a .qrc file containing keyboard layout and styles. I tried following tons of forums to no avail, but I believe the closest I came is through following https://forum.qt.io/topic/93279/how-to-custom-qml-virtual-keyboard. Now all links on Google are purple. Many of the guides and forums expect a QML application written in QMake, and I have not succeeded in translating these to my problem using CMake.
I have also asked this question here but haven't gotten answers in days.
My .qrc file is the following (with the default-style taken from here):
<RCC>
<qresource prefix="/">
<file>virtual_keyboard/QtQuick/VirtualKeyboard/layouts/en_GB/main.qml</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/layouts/en_GB/numbers.qml</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/textmode-fff.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/shift-fff.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/shift-c5d6b6.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/shift-80c342.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/settings-fff.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/selectionhandle-bottom.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/search-fff.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/hidekeyboard-fff.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/handwriting-fff.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/globe-fff.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/enter-fff.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/check-fff.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/images/backspace-fff.svg</file>
<file>virtual_keyboard/QtQuick/VirtualKeyboard/Styles/style/style.qml</file>
</qresource>
</RCC>
I know I need the following lines to use my custom layout and specify my style, here just named 'style'. The custom layout is loaded properly, but the style is not:
qputenv("QT_VIRTUALKEYBOARD_LAYOUT_PATH", "qrc:/virtual_keyboard/QtQuick/VirtualKeyboard/layouts");
qputenv("QT_VIRTUALKEYBOARD_STYLE", "style");
QApplication a(argc, argv);
...
return a.exec();
What I get from running my application in the following, which suggests that I am not importing from the right directory for whatever reason:
WARNING: Cannot find style "style" - fallback: "default"
What I've tried
As can be seen in the .qrc-file, I use the same path as they expect, e.g. .../QtQuick/VirtualKeyboard/Styles/_MYSTYLENAME_/...
, where _MYSTYLENAME_ = style
.
I tried putting qputenv("QML_IMPORT_PATH", "qrc:/virtual_keyboard")
and qputenv("QML2_IMPORT_PATH", "qrc:/virtual_keyboard")
before the lines above to enforce using styles from the .qrc-file, with no luck.
I've tried adding the following lines (below QApplication a(argc, argv)
or else it wouldn't run):
QQmlEngine qml_engine;
qml_engine.addImportPath("qrc:/virtual_keyboard");
Thanks in advance for any help!