I'm building an Application using PyQt6.4.0 on Ubuntu 20.04 and I intend to customize the style of my virtual keyboard to make it smaller when the user enters some text in a QLineEdit. I've followed these instructions to copy the virtual keyboard binaries into my installation folder.
I tried to follow these instructions when adding a custom keyboard style. Specifically, I copy the built-in styles in src/styles/builtin
from the qt virtualkeyboard repository into my PyQt installation folder: [PATH_TO_MY_VENV]/lib/python3.8/site-packages/PyQt6/Qt6/qml/QtQuick/VirtualKeyboard/Styles
, and rename the file folder as 'test'
. In my script, I set the environment variables:
os.environ["QML2_IMPORT_PATH"] = "[PATH_TO_MY_VENV]/lib/python3.8/site-packages/PyQt6/Qt6/qml"
os.environ["QT_VIRTUALKEYBOARD_STYLE"] = "test"
But I get the following warning, and my custom keyboard style does not appear:
WARNING: Cannot find style "test" - fallback: "default"
Investigating a bit further, I notice on the Qt documentation website that "The directory name can not contain spaces or special characters other than underscore." So I suspected that my pyqt installation path, containing '.'
and '-'
might've led to an invalid directory name. So I copied the QtQuick
directory over to /home/[USERNAME]/
(with no special characters) , add that folder to my QML import path and run my application again:
os.environ["QML2_IMPORT_PATH"] = "/home/[USERNAME]/"
os.environ["QT_VIRTUALKEYBOARD_STYLE"] = "test"
But I get the same warning as above.
I've looked at forums where people struggle with the same issue, such as this, this and this. Tried following their instructions but with not much success. It might've been something I did not pick up while reading - since I'm relatively new to PyQt too.