[Qt-qml] aliases
Henry Gomersall
heng at cantab.net
Tue Jun 28 13:31:02 CEST 2011
The documentation for aliases
(http://doc.qt.nokia.com/latest/qml-extending-types.html#default-properties) presents the following example:
// Button.qml
import QtQuick 1.0
Item {
property alias buttonText: textItem.text
width: 200; height: 50
Text { id: textItem }
}
with the comment:
"In this case, the use of aliased properties is essential. If buttonText
was not an alias, changing its value would not actually change the
displayed text at all, as property bindings are not bi-directional: the
buttonText value would change when textItem.text changes, but not the
other way around."
My question is, why is using aliases in this example better than the
following, which seems to achieve the same goal:
// Button.qml
import QtQuick 1.0
Item {
property string buttonText
width: 200; height: 50
Text { id: textItem; text: parent.buttonText }
}
Cheers,
Henry
More information about the Qt-qml
mailing list