summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Alpert <aalpert@rim.com>2012-11-06 16:29:04 -0800
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-15 21:37:07 +0100
commit62d159e977b137402da17a0eb3866af958dc4fca (patch)
treed7314a60a1a48a09735865d99c2bcef86fa5b8f6
parent53301b322982a5df805588f3fd114b2eb5ccda71 (diff)
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>
-rw-r--r--doc/src/declarative/codingconventions.qdoc6
-rw-r--r--doc/src/snippets/declarative/codingconventions/private.qml5
2 files changed, 6 insertions, 5 deletions
diff --git a/doc/src/declarative/codingconventions.qdoc b/doc/src/declarative/codingconventions.qdoc
index 7befaeb5bc..2774072d56 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 8375e33d2d..168e5f280e 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]