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

QML properties on C++ QQuickItems fail to parse with "import as"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 5.0.1
    • None
    • Win7/64, MSVC2010, Qt5.0.1 Commercial

    Description

      QQuickItem-derived C++ class imported to QML cannot be used as a "property" when "import as".

      WORKS:
      // FILE: MyItem0.qml
      import QtQuick 2.0
      import my.custom.cpp 1.0 //<==NOTE NO "as"

      Item {
      property MyCppType myCppType // WORKS
      }
      //...

      DOES NOT WORK (QML compile error):
      // FILE: MyItem1.qml
      import QtQuick 2.0
      import my.custom.cpp 1.0 as MyCpp //<==NOTE "as"

      Item {
      property MyCpp.MyCppType myCppType // NOT WORK
      }
      //...

      The compile error for "import as" is at the "dot" separating the "MyCpp" from "MyCppType", with an error:

      property MyCpp.MyCppType myCppType
      ^
      "Unexpected token '.'"

      The desired behavior is to permit user-defined types to be imported with the "import as" module name when those types are used as a "property".

      Attachments

        Issue Links

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

          Activity

            People

              aalpert Alan Alpert
              charleyb charley bay
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes