[Interest] Namespace on Custom C++ property in QML?

Charley Bay charleyb123 at gmail.com
Mon Feb 25 14:56:22 CET 2013


I'm sure this is a silly question, but why are these different:

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

Item {
  property MyCppType myCppType // WORKS
}

// FILE: MyItem1.qml
import QtQuick 2.0
import my.custom.cpp 1.0 as MyCpp   //<==NOTE "as"

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

QUESTION:  If I import the C++ custom types with an "as MyCpp", then I can
no longer use the type as a "property" within QML.  Dropping the
"as-module" name works.

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

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


I assume package/namespace/plugin scoping names are not allowed for
defining properties in QML?  Does this mean you can't use "as-namespaces"
in a QML file when you want that C++ type as a "property"?

Just curious.  Thanks!

--charley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130225/68af6e76/attachment.html>


More information about the Interest mailing list