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

QML Singletons require an explicit import to load qmldir file

XMLWordPrintable

      qmldir files are used to designate types as a singleton (in addition to having a pragma Singleton statement inside the qml type).

      qmldir files are not loaded automatically even if they exist in the same directory as the qml file. If all types are fully resolved without this, implicit loading does not happen. In those cases, if you need to use QML singletons you must add an explicit import.

      This may result in a lot of import "." statements.

      For example see the the SameGame modifications in patch https://codereview.qt-project.org/c/qt/qtdeclarative/+/69429

      Ideal fix would be to deduct when a QML Singleton is used and then drop the requirement for having the singleton also defined in the qmldir file. This may be possible in the future v4 compiler.

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            apiira Antti Piira
            Votes:
            34 Vote for this issue
            Watchers:
            37 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes