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

Singleton requirement for a qmldir is unfortunate; needs better handling.

XMLWordPrintable

      QML-defined singletons require a qmldir to be "found". If one imports a local directory containing a file marked with the singleton pragma, and attempts to use it, i.e:

      main.qml:

      import "stuff"
      
      Item {
          Component.onCompleted: console.log(StuffThing.foo)
      }
      

      stuff/StuffThing.qml:

      import QtQuick 2.6
      pragma Singleton
      
      Item {
          property int foo
      }
      

      ... will fail with an (unhelpful) ReferenceError: StuffThing is not defined, until one creates a qmldir mentioning the singleton.

      I think we should do one or more of the following:

      • Remove the qmldir requirement (better compatibility with non-singleton type resolution)
      • Document the qmldir requirement more clearly
      • See if we can improve the error reporting for this case, so it is clearer that singleton types require resolution here (might be hard).

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

            Unassigned Unassigned
            w00t Robin Burchell
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes