Hi Kim, Den 21-02-2014 17:00, kim kulling skrev: > Hi ML, > > I have the following situation: > I have my own plugin based on QML with specific c++-types and my own > qml-types defined in separate qml-files. This works fine. > > Now I also want to support 2 different color schemas in this plugin like: > > Myplugin/ > +-Styles+-Style1/Colors.qml > ...............Style1/Styles.qml > ...............Style1/qmldir > ...............Style2/Colors.qml > ...............Style2/Styles.qml > ...............Style2/qmldir > > In the file Style I only export the color schema as a property: > > Style.qml: > importQtQuick2.0 > > > Item { > > id: styles > > property alias colors: colors > > > Colors { > > id: colors > > } > > } > > > the qmldir for style1 looks like: > > > module Myplugin.Styles.Style1 > typeinfo plugins.qmltypes > Styles 1.0 Styles.qml > > > Same for Style2 with changed numers for the styles. > > > Now I am trying to assecc the colors via: > > > importMyplugin.Styles.Style1 as Style1 > > > Rectangle { > > color:Style1.styles.colors > > } > > > And I am getting the following error message: > > > Unable to assign [undefined] to QColor > > > I am not sure if this is the right way to go or what I'm currently doing > wrong. Any ideas?
I can't tell you exactly what's going on here, but I can give you a couple of pointers on what I would do. 1) Check if you can access an int in the styles item from your rectangle. Something like this would work: Item { id: styles property int foo: 1 } Rectangle { color: Style1.styles.foo == 1 ? "yellow" : "red" } 2) In your Rectangle, it looks like you are assinging the full Colors object to the color on the rectangle. 3) You can alias the Colors contents directly in the styles. Yes, I would also prefer avoiding this, but it would mean users don't have to know the Colors type. I hope this helps. -- Bo Thorsen, European Engineering Manager, ICS Meet me at our quickstarts across Europe in March. London, Copenhagen, Hamburg, Munich and Zurich. See this page: http://ics.com/qt-quickstart _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest