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

QJSEngine::registerModule not respected under qml

    XMLWordPrintable

Details

    • macOS, Windows
    • b297e8fccf (qt/qtdeclarative/dev) b297e8fccf (qt/tqtc-qtdeclarative/dev)

    Description

      According to these docs: https://doc.qt.io/qt-6/qjsengine.html

      It is supposed to be possible to register virtual JavaScript modules that are not backed by files using QJSEngine::registerModule.

      I.e something like this:

      QJSValue name("Qt6");
      QJSValue obj = myEngine.newObject();
      obj.setProperty("name", name);
      myEngine.registerModule("info", obj);
      
      import { name } from "info";
      
      export function getName()
      {
          return name;
      }
      

      However these modules do not appear to be accessible at all from either QML or more importantly javascript files imported from QML files.

      Attached is a simple test project that I would have expected to work given the above docs.

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            haiku Ollie Dawes
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes