Hi Stephen,

My understanding is that an Item placed inside a widget will be included in the UI tree at that place, and hence displayed, which you don't want, say, if you've designed your component to be used as a "template" or a"lens" in order to be used by a View to render Items that are inside a Model.
I hope this helps.
Best,
Sacha

Also, quoting from http://doc.trolltech.org/4.7-snapshot/qml-component.html:

For example, here is a component that is used by multiple Loader <http://doc.trolltech.org/4.7-snapshot/qml-loader.html> objects:

 Item {
     Component {
         id: redSquare

         Rectangle {
             color:"red"
             width: 10
             height: 10
         }
     }

     Loader { sourceComponent: redSquare }
     Loader { sourceComponent: redSquare; x: 20 }
 }

Notice that while a Rectangle <http://doc.trolltech.org/4.7-snapshot/qml-rectangle.html> by itself would be automatically rendered and displayed, this is not the case for the above rectangle because it is defined inside a Component. The component encapsulates the QML elements within, as if they were defined in a separate .qml file, and is not loaded until requested (in this case, by the two Loader <http://doc.trolltech.org/4.7-snapshot/qml-loader.html> objects).



On 07/22/2010 11:25 AM, Stephen Collyer wrote:
Could someone explain the purpose of the Component element ?
I can't see what it allows you to do that can't be done with an Item.


_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-qml

_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-qml

Reply via email to