diff options
author | Alan Alpert <aalpert@rim.com> | 2012-11-07 00:29:04 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-15 20:37:07 (GMT) |
commit | 62d159e977b137402da17a0eb3866af958dc4fca (patch) | |
tree | d7314a60a1a48a09735865d99c2bcef86fa5b8f6 /doc/src | |
parent | 53301b322982a5df805588f3fd114b2eb5ccda71 (diff) | |
download | Qt-62d159e977b137402da17a0eb3866af958dc4fca.zip Qt-62d159e977b137402da17a0eb3866af958dc4fca.tar.gz Qt-62d159e977b137402da17a0eb3866af958dc4fca.tar.bz2 |
Fix code convention docs
The previously specified convention prevents change handlers from
being created properly. Another convention is being suggested instead.
Task-number: QTBUG-27852
Change-Id: I32a3f6f6c01e628457b30479505b32f1c5bbc92c
Reviewed-by: Alan Alpert (RIM) <aalpert@rim.com>
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/declarative/codingconventions.qdoc | 6 | ||||
-rw-r--r-- | doc/src/snippets/declarative/codingconventions/private.qml | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/doc/src/declarative/codingconventions.qdoc b/doc/src/declarative/codingconventions.qdoc index 7befaeb..2774072 100644 --- a/doc/src/declarative/codingconventions.qdoc +++ b/doc/src/declarative/codingconventions.qdoc @@ -76,10 +76,8 @@ can be written like this: QML and JavaScript do not enforce private properties like C++. There is a need to hide these private properties, for example, when the properties are part of -the implementation. As a convention, private properties begin with two -\e underscore characters. For example, \c __area, is a property that is -accessible but is not meant for public use. Note that QML and JavaScript will -grant the user access to these properties. +the implementation. To effectively gain private properties in a QML Item, the +convention is to add a QtObject{} child to contain the properties. This shields them from being accessed outside the file in QML and JavaScript. As it involves the creation of another object, it is more expensive than just creating a property. To minimize the performance cost, try to group all private properties in one file into the same QtObject. \snippet doc/src/snippets/declarative/codingconventions/private.qml 0 diff --git a/doc/src/snippets/declarative/codingconventions/private.qml b/doc/src/snippets/declarative/codingconventions/private.qml index 8375e33..168e5f2 100644 --- a/doc/src/snippets/declarative/codingconventions/private.qml +++ b/doc/src/snippets/declarative/codingconventions/private.qml @@ -44,6 +44,9 @@ import QtQuick 1.0 Item { id: component width: 40; height: 50 - property real __area: width * height * 0.5 //not meant for outside use + QtObject { + id: d + property real area: width * height * 0.5 //not meant for outside use + } } //! [0] |