Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-104109

VirtualKeyboard not working under WebAssembly

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3: Somewhat important
    • 6.4.0 Beta4
    • 6.2.4, 6.4.0 FF
    • Virtual Keyboard
    • None
    • WebAssembly, Windows

    Description

      Steps:

      1) Open QtCreator

      2) File -> New File Or Project -> Qt Quick Application -> Choose.

      3) Specify location and project name

      4) Select CMake as the build system

      5) Select minimal Qt version as either 6.2 or 6.4, and check the "Use Qt Virtual Keyboard" checkbox.

      6) Select appropriate kit (either Qt for WebAssembly 6.2.4 or Qt For WebAssembly 6.4.0)

      7) Create the project.

       

      This results in the following code files:

      a) CMakeLists.txt

      cmake_minimum_required(VERSION 3.16)
      
      project(vkbtest VERSION 0.1 LANGUAGES CXX)
      
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
      find_package(Qt6 6.4 COMPONENTS Quick REQUIRED)
      
      qt_add_executable(appvkbtest
          main.cpp
      )
      
      qt_add_qml_module(appvkbtest
          URI vkbtest
          VERSION 1.0
          QML_FILES main.qml
      )
      
      target_compile_definitions(appvkbtest
          PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
      target_link_libraries(appvkbtest
          PRIVATE Qt6::Quick)

      b) main.cpp

      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      
      
      int main(int argc, char *argv[])
      {
          qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
          
          QGuiApplication app(argc, argv);
          
          QQmlApplicationEngine engine;
          const QUrl url(u"qrc:/vkbtest/main.qml"_qs);
          QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                           &app, [url](QObject *obj, const QUrl &objUrl) {
              if (!obj && url == objUrl)
                  QCoreApplication::exit(-1);
          }, Qt::QueuedConnection);
          engine.load(url);
          
          return app.exec();
      }
       

      b) main.qml

       import QtQuick 
      import QtQuick.VirtualKeyboard
      
      Window {
          id: window
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
          
          InputPanel {
              id: inputPanel
              z: 99
              x: 0
              y: window.height
              width: window.width
              
              states: State {
                  name: "visible"
                  when: inputPanel.active
                  PropertyChanges {
                      target: inputPanel
                      y: window.height - inputPanel.height
                  }
              }
              transitions: Transition {
                  from: ""
                  to: "visible"
                  reversible: true
                  ParallelAnimation {
                      NumberAnimation {
                          properties: "y"
                          duration: 250
                          easing.type: Easing.InOutQuad
                      }
                  }
              }
          }
      }

       

      Build and run with Qt 6.2.4, this results in errors, due to VirtualKeyboard import not being available.  I assume it's due to static linkage being required in WebAssembly builds, so then:

       

      Step 8) modify CMakeLists.txt to include VirtualKeyboard package and linkage like:

      find_package(Qt6 COMPONENTS Quick VirtualKeyboard REQUIRED) 
      target_link_libraries(appvkbtest PRIVATE Qt6::Quick Qt6::VirtualKeyboard)

       

      Build and run with Qt 6.2.4, this results in errors, due to VirtualKeyboard.Plugins import not being available:

      QQmlApplicationEngine failed to load component
      qtloader.js:382 qrc:/vkbtest/main.qml:11:5: Type InputPanel unavailable
      qtloader.js:382 qrc:/QtQuick/VirtualKeyboard/content/InputPanel.qml:131:5: Type Keyboard unavailable
      qtloader.js:382 qrc:/QtQuick/VirtualKeyboard/content/components/Keyboard.qml:38:1: module "QtQuick.VirtualKeyboard.Plugins" is not installed

      Build with Qt 6.4.0 (pre-release), get the following build-time errors:

      17:02:34: Running steps for project vkbtest...
      17:02:34: Starting: "C:\Development\Qt\Tools\CMake_64\bin\cmake.exe" --build D:/code/vkbtest/build-vkbtest-WebAssembly_Qt_6_4_0-Debug --target all
      jom: parallel job execution disabled for Makefile
      [  5%] Built target appvkbtest_tooling
      [ 11%] Generating .rcc/qmlcache/appvkbtest_qmlcache_loader.cpp
      [ 16%] Automatic MOC for target appvkbtest
      [ 16%] Built target appvkbtest_autogen
      [ 22%] Running AUTOMOC file extraction for target appvkbtest
      [ 22%] Built target appvkbtest_automoc_json_extraction
      [ 33%] Running moc --collect-json for target appvkbtest
      [ 33%] Running rcc for resource appvkbtest_raw_qml_0
      [ 38%] Running rcc for resource qmake_vkbtest
      [ 44%] Automatic QML type registration for target appvkbtest
      [ 50%] Generating .rcc/qmlcache/appvkbtest_main_qml.cpp
      Consolidate compiler generated dependencies of target appvkbtest
      [ 55%] Building CXX object CMakeFiles/appvkbtest.dir/appvkbtest_autogen/mocs_compilation.cpp.o
      [ 66%] Building CXX object CMakeFiles/appvkbtest.dir/.rcc/qrc_qmake_vkbtest.cpp.o
      [ 66%] Building CXX object CMakeFiles/appvkbtest.dir/main.cpp.o
      [ 77%] Building CXX object CMakeFiles/appvkbtest.dir/.rcc/qmlcache/appvkbtest_qmlcache_loader.cpp.o
      [ 77%] Building CXX object CMakeFiles/appvkbtest.dir/.rcc/qrc_appvkbtest_raw_qml_0.cpp.o
      [ 88%] Building CXX object CMakeFiles/appvkbtest.dir/.rcc/qmlcache/appvkbtest_main_qml.cpp.o
      [ 88%] Building CXX object CMakeFiles/appvkbtest.dir/appvkbtest_qmltyperegistrations.cpp.o
      [ 94%] Linking CXX executable appvkbtest.js
      error: undefined symbol: _Z53qt_static_plugin_QtQuick_VirtualKeyboard_StylesPluginv (referenced by top-level compiled C/C++ code)
      warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
      warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
      warning: __Z53qt_static_plugin_QtQuick_VirtualKeyboard_StylesPluginv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
      error: undefined symbol: _Z61qt_static_plugin_QtQuick_VirtualKeyboard_Styles_BuiltinPluginv (referenced by top-level compiled C/C++ code)
      warning: __Z61qt_static_plugin_QtQuick_VirtualKeyboard_Styles_BuiltinPluginv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
      Error: Aborting compilation due to previous errors
      em++: error: 'C:/Development/emscripten/emsdk/node/14.18.2_64bit/bin/node.exe C:\Development\emscripten\emsdk\upstream\emscripten\src\compiler.js C:\Users\chris\AppData\Local\Temp\tmpvstp4zw8.json' failed (returned 1)
      jom: D:\code\vkbtest\build-vkbtest-WebAssembly_Qt_6_4_0-Debug\CMakeFiles\appvkbtest.dir\build.make [appvkbtest.js] Error 1
      jom: D:\code\vkbtest\build-vkbtest-WebAssembly_Qt_6_4_0-Debug\CMakeFiles\Makefile2 [CMakeFiles\appvkbtest.dir\all] Error 2
      jom: D:\code\vkbtest\build-vkbtest-WebAssembly_Qt_6_4_0-Debug\Makefile [all] Error 2
      17:02:42: The process "C:\Development\Qt\Tools\CMake_64\bin\cmake.exe" exited with code 2.
      Error while building/deploying project vkbtest (kit: WebAssembly Qt 6.4.0)
      The kit WebAssembly Qt 6.4.0 has configuration issues which might be the root cause for this problem.
      When executing step "Build"
      17:02:42: Elapsed time: 00:08. 

       

      Note that I'm using emscripten 2.0.14 with Qt 6.2.4 and emscripten 3.1.6 with Qt 6.4.0.

       

      I'm building on Windows, for WebAssembly, and opening with Chrome.

       

      The error message in the Qt 6.2.4 case is similar to what was seen in QTBUG-76931 – I don't know whether this is a regression from Qt 5.13, or whether I am doing something wrong (e.g. do I manually need to Q_IMPORT_PLUGIN in main.cpp to force static linkage?)

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            lpotter Lorn Potter
            chrisadams Christopher Adams
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes