[Qt-qml] Accessing dynamic properties
aaron.kennedy at nokia.com
aaron.kennedy at nokia.com
Thu Sep 16 12:24:58 CEST 2010
Hi,
On 16/09/2010, at 7:59 PM, "Dzyubenko Denis (Nokia-MS-Qt/Oslo)" <denis.dzyubenko at nokia.com> wrote:
> Hi,
>
>> No it doesn't work, and no its not supposed to work. Qt's dynamic
>> properties do not fit the QML model very well which relies on knowing the
>> complete static type of an object prior to instantiation, and we'd prefer
>> not to support them.
>
> it sounds a bit strange to me, but if it is a conscious decision they I can live with that.
>
> Though it would be convenient to get access to dynamic properties if the user explicitly asks for them in QML - for example it would be convenient to have something like that in QML;
>
> MyQMLItem {
> Item {
> width: parent.dynamicProperty("my_dynamic_property") // mark explicitly that we want a dynamic property
> }
> }
We could add that, but it seems a little clunky.
>> Perhaps if you give more details about the actual problem you are trying to
>> solve we can think of an alternative way.
>
> It is mostly for prototyping in the QML Gestures project - we would want to expose new properties for QML on objects inside QtGui but we are not sure if we want to have them in the final version. Of course we could use Q_PRIVATE_PROPERTY, but for that we need to modify Qt gui itself. Right now our research code is in the qml import module - so it would be much more convenient if we could set some properties on objects in Qt from inside the qml plugin, and them access them from the qml document without creating wrappers in the qml module.
An extension object could be used for exactly this purpose. http://doc.trolltech.org/4.7-snapshot/qml-extending.html#extension-objects
Cheers,
Aaron
More information about the Qt-qml
mailing list