Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. custom style for virtual keyboard
Forum Updated to NodeBB v4.3 + New Features

custom style for virtual keyboard

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 3 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mzimmers
    wrote on 15 Mar 2024, 23:03 last edited by mzimmers
    #1

    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 R 3 Replies Last reply 16 Mar 2024, 09:02
    0
    • M Offline
      M Offline
      mzimmers
      wrote on 16 Mar 2025, 23:41 last edited by
      #8

      OK, so here's what I needed to do:

      • create a resource file for the custom style.
      • add a prefix:
          <qresource prefix="/VKeyboardStyles/QtQuick/VirtualKeyboard/Styles/mydefault">
      
      • create a folder with the name "mydefault"
      • place my custom style.qml in this folder (along with any custom images I wanted)
      • add this to my main.cpp:
          qputenv("QT_VIRTUALKEYBOARD_STYLE","mydefault");
      

      I really don't see why this has to be so complicated, but maybe this will help anyone else who's trying to do the same thing.

      Thanks to everyone who looked.

      1 Reply Last reply
      0
      • M mzimmers
        15 Mar 2024, 23:03

        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 Offline
        J Offline
        JonB
        wrote on 16 Mar 2024, 09:02 last edited by
        #2

        @mzimmers said in custom style for virtual keyboard:

        I'm looking at the docs

        This is not a good link since it just points to this page!

        M 1 Reply Last reply 16 Mar 2024, 13:51
        0
        • J JonB referenced this topic on 16 Mar 2024, 09:02
        • M mzimmers
          15 Mar 2024, 23:03

          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...

          R Offline
          R Offline
          Ronel_qtmaster
          wrote on 16 Mar 2024, 09:43 last edited by
          #3

          @mzimmers did you check this? https://forum.qt.io/topic/93279/how-to-custom-qml-virtual-keyboard

          1 Reply Last reply
          1
          • J JonB
            16 Mar 2024, 09:02

            @mzimmers said in custom style for virtual keyboard:

            I'm looking at the docs

            This is not a good link since it just points to this page!

            M Offline
            M Offline
            mzimmers
            wrote on 16 Mar 2024, 13:51 last edited by
            #4

            @JonB oops. Corrected. Thanks.

            1 Reply Last reply
            0
            • M mzimmers
              15 Mar 2024, 23:03

              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 Offline
              J Offline
              JonB
              wrote on 16 Mar 2024, 14:09 last edited by JonB
              #5

              @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 up QtQuick/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.

              M 1 Reply Last reply 16 Mar 2024, 16:57
              1
              • J JonB
                16 Mar 2024, 14:09

                @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 up QtQuick/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.

                M Offline
                M Offline
                mzimmers
                wrote on 16 Mar 2024, 16:57 last edited by
                #6

                @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.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mzimmers
                  wrote on 9 Feb 2025, 19:36 last edited by
                  #7

                  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...

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mzimmers
                    wrote on 16 Mar 2025, 23:41 last edited by
                    #8

                    OK, so here's what I needed to do:

                    • create a resource file for the custom style.
                    • add a prefix:
                        <qresource prefix="/VKeyboardStyles/QtQuick/VirtualKeyboard/Styles/mydefault">
                    
                    • create a folder with the name "mydefault"
                    • place my custom style.qml in this folder (along with any custom images I wanted)
                    • add this to my main.cpp:
                        qputenv("QT_VIRTUALKEYBOARD_STYLE","mydefault");
                    

                    I really don't see why this has to be so complicated, but maybe this will help anyone else who's trying to do the same thing.

                    Thanks to everyone who looked.

                    1 Reply Last reply
                    0
                    • M mzimmers has marked this topic as solved on 16 Mar 2025, 23:41

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved