Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. qt_add_qml_module code works for desktop but not for wasm

qt_add_qml_module code works for desktop but not for wasm

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
2 Posts 2 Posters 104 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.
  • fullQiF Offline
    fullQiF Offline
    fullQi
    wrote last edited by
    #1

    Create main UI module

    qt_add_qml_module(UiLib
    URI "UI"
    VERSION 1.0
    OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qml_modules/UI
    QML_FILES
    qml/Main.qml
    qml/login/LoginWindow.qml
    qml/login/LoginView.qml
    qml/login/RegisterView.qml
    qml/login/ForgotPasswordView.qml
    qml/login/EmailVerificationView.qml
    qml/login/LoginGlowOrbs.qml
    qml/login/LoginBorderOrbs.qml
    IMPORTS
    QtQuick
    QtQuick.Controls
    QtQuick.Dialogs
    QtQuick.Layouts
    QtMultimedia
    )

    loadFromModule("UI", "Main")

    the loadFromModule works for my desktop build but not in the browser for some reason

    the files are reachable through their qrc:/ path (qrc:/qt/qml/qml/Main.qml, etc) but not as modules.

    dealing with these qrc paths is just too great of an hassle, importing, lsp and linting into code make me feel like I am doing surgery in mud with a kitchen knife and toothpicks

    1 Reply Last reply
    0
    • Axel SpoerlA Offline
      Axel SpoerlA Offline
      Axel Spoerl
      Moderators
      wrote last edited by
      #2

      Hi,
      please format your code, using the </> code formatting tags. It makes just so much easier to read.
      WASM is a bit stricter than other OSes when it comes to deployment and embedded resources.
      Most certainly adding

      RESOURCE_PREFIX /qt/qml
      

      right above the imports will solve the problem.

      Software Engineer
      The Qt Company, Oslo

      1 Reply Last reply
      1

      • Login

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