Details
-
Suggestion
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.7.1
-
None
Description
The QML documentation seems to suggest that it is optional to define a custom component
in a separate QML file, in fact it not always is, as components defined inline cannot be given
a type-name, only an instance-id.
import Qt 4.7 Rectangle { width: 640; height: 480; // This works because an instance of "blueRect" is created (?) here Component { id: "blueRect" Rectangle { width: 100 height: 100 color: "blue" } } Repeater { model: 1 delegate: blueRect // blue-rect instance used here } // Can't instantiate a component from an instance-id blueRect { x: 200; y: 100 } // This syntax is not supported. The component needs to be moved to RedRect.qml Component RedRect { Rectangle { width: 100 height: 100 color: "red" } } // None of this will only work unless RedRect is moved to RedRect.qml RedRect { x: 200; y: 200 } RedRect { x: 300; y: 300 } Repeater { model: 1 delegate: RedRect {} } }