[Qt-qml] no basic property define confuse

Eduardo Fleury eduardo.fleury at openbossa.org
Wed Sep 29 22:52:27 CEST 2010


Sorry I have to replying to myself once again. :-)

Caio and Daker here at the office pointed a mistake in my previous answer.


On Wed, Sep 29, 2010 at 3:52 PM, Eduardo Fleury <
eduardo.fleury at openbossa.org> wrote:

> or else, use a Loader to show it somewhere else:
>
> Rectangle {
>     Loader {
>         delegate: myProperty   // assuming this is an initialized property
> of type Text
>     }
> }
>


This is wrong in two ways:
1) The name of the property I intended to say is "sourceComponent", not
"delegate".
2) As the name implies, it expects a Component, not a an Item (or Text). You
can make "myProperty" of the type "Component" and that will work, but in
that case you won't create the Text object yourself, instead will will be
defining a Component and creating an instance of Text dynamically using
Loader. (See Component and Loader docs for more info).


The short answer to make your first item be shown on the screen is to set
its parent accordingly by doing:

myText1.parent = someOtherItemId

See attached example.

BR,
Eduardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100929/3b72f8c7/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parentChangeTest.qml
Type: application/octet-stream
Size: 620 bytes
Desc: not available
Url : http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20100929/3b72f8c7/attachment.obj 


More information about the Qt-qml mailing list