PDA

View Full Version : QObject dynamic properties and QML binding



ugluk
14th December 2012, 10:39
Say I have this:



Rectangle {
width: object.dynamicProperty
}


If dynamicProperty changes no dynamicPropertyChanged signal will be issued, hence width won't change. Is it possible to somehow simulate a NOTIFY signal for a dynamic QObject property?

Le_B
18th December 2012, 09:58
what kind of object is "object" c++, custom qml,... ?

Urthas
20th December 2012, 06:36
If dynamicProperty changes no dynamicPropertyChanged signal will be issued, hence width won't change.

Are you sure, as in, you've conclusively demonstrated this in your working code? From the docs (http://doc.qt.digia.com/qt/propertybinding.html):


The property value is automatically kept up to date if the other properties or data values change.

wysota
20th December 2012, 09:10
The value is kept updated only if a notification signal is sent by the C++ object containing the property.

@ugluk: Why do you need a dynamic property to be reflected in QML? Can't you use a real property instead?

ugluk
21st December 2012, 12:07
No, I can't. I thought that there perhaps exists a way to send a dynamic signal. I think that dynamic properties would fit well with a scripting language (which is also dynamic).

"object" is a C++ object (inheriting QObject).

wysota
21st December 2012, 23:43
Why can't you use real properties?