custom style for virtual keyboard
-
Hi all -
I'm looking at the docs for customizing a virtual keyboard (I just want to change the color scheme). Do I correctly understand that the folder containing my custom style must be under src/virtualkeyboard/content/styles? I'd greatly prefer not to write into this area (or anywhere in the Qt installation.
Can I just put the folder within my project area? If so, do I need to set an environment variable so the application will find it at run time?
Thanks...
-
J JonB referenced this topic on
-
@mzimmers did you check this? https://forum.qt.io/topic/93279/how-to-custom-qml-virtual-keyboard
-
@mzimmers
Right. So I know nothing about this, but it's Saturday and not many people are here :) Per your doc link, I think you need to read/understand the section after it, Adding Custom Styles. You fiddle with/set upQtQuick/VirtualKeyboard/Styles/
"virtual URL" and read QML Import Path for where you can put files and get it to look there for them. I don't think you have to "write into [...] anywhere in the Qt installation".And doubtless read @Ronel_qtmaster's link too.
-
@JonB perhaps I misunderstood this line:
The process of creating a new style begins by creating a new subdirectory for the style in a QML import path under the URL-based directory structure QtQuick/VirtualKeyboard/Styles/.
@Ronel_qtmaster the link you provided is helpful, though some of the information in the earlier posts seems to be out of date (for example, the pathname for the style files no longer contains a "content" folder).
Also, there appears to be multiple locations mentioned for the style files:
- C:\Qt\6.5.3\mingw_64\qml\QtQuick\VirtualKeyboard\Styles\Builtin
- C:\Qt\6.5.3\Src\qtvirtualkeyboard\src\styles\builtin
I think the first one might be out of date, though I'm not sure about this.
-
I bet you guys thought I'd forgotten about this...
So, I've added this to my CMakeLists.txt file:
add_compile_definitions( CMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}" CMAKE_PROJECT_NAME="${CMAKE_PROJECT_NAME}" )
And, in my main.cpp:
QString stylePath = CMAKE_BINARY_DIR; stylePath.append("/"); stylePath.append(CMAKE_PROJECT_NAME); stylePath.append("/QtQuick/VirtualKeyboard/Styles/test"); stylePath = QDir::toNativeSeparators(stylePath); qputenv("QT_VIRTUALKEYBOARD_STYLE", stylePath.toUtf8()); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.addImportPath(":/QtQuick/VirtualKeyboard/Styles/test");
But at runtime, I get a warning:
WARNING: Cannot find style "C:\\Users\\michael.zimmers\\Qt_projects\\keyboard\\build\\Desktop_Qt_6_8_1_MinGW_64_bit-Debug\\keyboard\\QtQuick\\VirtualKeyboard\\Styles\\test" - fallback: "default"
Does anyone have an idea as to what am I missing?
Thanks...