Search code examples
pythonqtpyqtpyqt5qtvirtualkeyboard

QtVirtualKeyboard - Change layout not working


Following the QT-API I got to make the custom style working putting it inside the correct folder and make the required modification from here. Now I have tried to use my own custom LAYOUT making the following modifications:

  1. I took the en_GB folder from /Qt/5.8/Src/qtvirtualkeyboard/src/virtualkeyboard/content/layouts/en_GB
  2. Copied to my own path and renamed it to customkblayout.
  3. Modified its main.qml file from ... Key { key: Qt.Key_Q text: "q" } ... to ... Key { key: Qt.Key_Q text: "w" } ... to see if it changed when I open the keyboard.

  4. Set the variable environment os.environ["QT_VIRTUALKEYBOARD_LAYOUT_PATH"] = ".../customkblayout"

These are all the variable environment I changed:

os.environ["QT5DIR"] = ".../Qt/5.8/gcc_64"
os.environ["QT_QPA_PLATFORM_PLUGIN_PATH"] = ".../Qt/5.8/gcc_64/plugins/platforms"
os.environ["QT_PLUGIN_PATH"] = ".../Qt/5.8/gcc_64/plugins"
os.environ["QML_IMPORT_PATH"] = ".../Qt/5.8/gcc_64/qml"
os.environ["QML2_IMPORT_PATH"] = ".../Qt/5.8/gcc_64/qml"
os.environ["QT_VIRTUALKEYBOARD_LAYOUT_PATH"] = ".../customkblayout"
os.environ["QT_VIRTUALKEYBOARD_STYLE"] = "custom"

os.environ["QT_IM_MODULE"] = "qtvirtualkeyboard"

Problem: When I open the qtvirtualkeyboard it seems that the variable environment is not working at all. It keeps the default layout that I don't even know where it's coming from. I even tried to modify the main.qml inside its own folder in .../en_GB and recompile it through QtCreator and nothing changes too.

Question: Is there any other variable I'm missing out? What am I doing wrong? Can't figure out how to change it and can't find anywhere how to do it more then I have already done.

Continuation of this question, where I tried to use style and already got this part, now only missing the Layout part.


Solution

  • Looking at your code, you are referencing Qt 5.8, but the QT_VIRTUALKEYBOARD_LAYOUT_PATH environment variable was added in Qt 5.9.

    Please see the commit here tagged Qt 5.9: https://github.com/qt/qtvirtualkeyboard/commit/d51fd422289d8077ef23dd3b5f8d2df6827787b6

    Hope that helps!