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

QML module api usage semantics are confusing

    XMLWordPrintable

Details

    • 70a2c0491d66aa05f9e9e67f8a845f4df84da857

    Description

      QML module api's are contextless, (per-engine) singleton types which can be registered just like any other type. Currently, however, to use the type, an import qualifier must be specified, and the functions/properties of the type are accessed through the qualifier. This is inconsistent to the way other types are used.

      For example, the current semantics:

      import MyComponents 1.0 as C
      
      C.BlueRectangle {
          property int borderWidht: C.BlueRectangle.BorderWidth // enum
          property int random: C.getRandom() // module api func
      }
      

      is confusing, since there is no way to tell what in C is providing the "getRandom()" function; furthermore, only one type in C could be providing it (or resolution conflicts would occur). It would be more consistent if it were:

      import MyComponents 1.0 as C
      
      C.BlueRectangle {
          property int borderWidht: C.BlueRectangle.BorderWidth // enum
          property int random: C.PRNG.getRandom() // module api func
      }
      

      The semantics of qualified module API imports should be fixed.
      Also, the name of the moduleApi type should be changed, since it really is just a singleton type.

      Attachments

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

        Activity

          People

            chriadam Christopher Adams (closed Nokia identity) (Inactive)
            chriadam Christopher Adams (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes