Re: [Qt-qml] Change property of dynamically created component

2010-11-10 Thread shiping.ji
Hi,

This explains the case, now we fully understood what was wrong in our approach.

Thanks a lot for Michael and Warwick's help.

BR,
Shiping 

-Original Message-
From: Brasser Michael (Nokia-MS-Qt/Brisbane) 
Sent: 11 November, 2010 03:43
To: Ji Shiping (Nokia-MS/Espoo)
Cc: qt-qml@trolltech.com
Subject: Re: [Qt-qml] Change property of dynamically created component

Hi Shiping,

id's are scoped to the component in which they are defined (and are accessible 
to subcomponents, but not to containing components) -- perhaps this is the 
problem you are running into? For example:

// YellowRect.qml
Rectangle {
id: yellowRect
width: 100
height: 100
color: yellow
}

//invalid.qml
Rectangle {
YellowRect {}
Rectangle {
color: yellowRect.color // ### this is invalid, as the id yellowRect 
is not accessible in this context
}
}

//valid.qml
Rectangle {
YellowRect { id: myRect }
Rectangle {
color: myRect.color // ### this is valid, as the id myRect is 
accessible in this context
}
}

Likewise, if YellowRect was dynamically created and placed into component X, 
the yellowRect id would not be visible in the context of X.

Regards,
Michael

On 10/11/2010, at 7:39 PM, ext shiping...@nokia.com wrote:

 Hi,
 
 That solves the problem. One more related question, does it mean that 
 dynamically created QML objects (incl. e.g. the one created using 
 QDeclarativeComponent::create()) will not have their id registered?
 
 We've noticed the issue that once we load and attach such objects 
 programmatically, future binding update to these newly created objects will 
 not work as it complains the object with the given id is not found. This has 
 nothing to do with the loader though. Please confirm and we will send some 
 sample code if you believe it should work and there is something wrong in our 
 side.
 
 Thanks again.
 
 BR,
 Shiping
 
 -Original Message-
 From: Allison Warwick (Nokia-MS-Qt/Brisbane) 
 Sent: 10 November, 2010 02:55
 To: Ji Shiping (Nokia-MS/Espoo); Jones Martin (Nokia-MS-Qt/Brisbane); 
 qt-qml@trolltech.com
 Subject: RE: Change property of dynamically created component
 
 The id of a component does not become a new global identifier. i.e. 
 yellowRect below:
 
Component {
id: yellowRectComponent
Rectangle {
id: yellowRect
width: 100
height: 100
color: yellow
}
}
 
 As you can imagine: if you had 2 loaders that loaded this, what would happen?
 
 So, to fix your example, instead of:
 
PropertyChanges {
target: yellowRect
color: gray
}
 
 You need:
 
PropertyChanges {
target: loader.item
color: gray
}
 
 --
 Warwick
 
 ___
 Qt-qml mailing list
 Qt-qml@trolltech.com
 http://lists.trolltech.com/mailman/listinfo/qt-qml


___
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml


[Qt-qml] Change property of dynamically created component

2010-11-08 Thread shiping.ji
Hi,

We have a QML with two states and one loader component. In state2, a new 
component yellowRectComponent is created by the loader. In state3, we'd 
like to modify this newly created component's properties, but it doesn't seem 
to work (the new component creation is successful though).

Do you know whether this is supported scenario or there is alternative way of 
achieving this?

Thanks.

BR,
Shiping

___
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml


Re: [Qt-qml] Change property of dynamically created component

2010-11-08 Thread martin.jones
There's nothing wrong with this in concept.  Could you provide a small 
self-contained example of what you've tried?

Martin.

 -Original Message-
 From: qt-qml-boun...@trolltech.com [mailto:qt-qml-boun...@trolltech.com] On
 Behalf Of Ji Shiping (Nokia-MS/Espoo)
 Sent: Tuesday, 9 November 2010 4:15 AM
 To: qt-qml@trolltech.com
 Subject: [Qt-qml] Change property of dynamically created component
 
 Hi,
 
 We have a QML with two states and one loader component. In state2, a new
 component yellowRectComponent is created by the loader. In state3, we'd 
 like
 to modify this newly created component's properties, but it doesn't seem to 
 work
 (the new component creation is successful though).
 
 Do you know whether this is supported scenario or there is alternative way of
 achieving this?
 
 Thanks.
 
 BR,
 Shiping
 
 ___
 Qt-qml mailing list
 Qt-qml@trolltech.com
 http://lists.trolltech.com/mailman/listinfo/qt-qml

___
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml


Re: [Qt-qml] Change property of dynamically created component

2010-11-08 Thread shiping.ji
Hi,

Forgot the attachment, here it comes :)
 
BR,
Shiping

-Original Message-
From: Jones Martin (Nokia-MS-Qt/Brisbane) 
Sent: 09 November, 2010 01:05
To: Ji Shiping (Nokia-MS/Espoo); qt-qml@trolltech.com
Subject: RE: Change property of dynamically created component

There's nothing wrong with this in concept.  Could you provide a small 
self-contained example of what you've tried?

Martin.

 -Original Message-
 From: qt-qml-boun...@trolltech.com [mailto:qt-qml-boun...@trolltech.com] On
 Behalf Of Ji Shiping (Nokia-MS/Espoo)
 Sent: Tuesday, 9 November 2010 4:15 AM
 To: qt-qml@trolltech.com
 Subject: [Qt-qml] Change property of dynamically created component
 
 Hi,
 
 We have a QML with two states and one loader component. In state2, a new
 component yellowRectComponent is created by the loader. In state3, we'd 
 like
 to modify this newly created component's properties, but it doesn't seem to 
 work
 (the new component creation is successful though).
 
 Do you know whether this is supported scenario or there is alternative way of
 achieving this?
 
 Thanks.
 
 BR,
 Shiping
 
 ___
 Qt-qml mailing list
 Qt-qml@trolltech.com
 http://lists.trolltech.com/mailman/listinfo/qt-qml


TestPropertyChanges.qml
Description: TestPropertyChanges.qml
___
Qt-qml mailing list
Qt-qml@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-qml