summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorJerome Pasion <jerome.pasion@nokia.com>2011-02-17 14:39:48 (GMT)
committerJerome Pasion <jerome.pasion@nokia.com>2011-02-17 14:39:48 (GMT)
commit6ff22762df68d60288cdc95b9359ca2544bd7bbe (patch)
treeece3f11c608522ff3fb6912ab0fb4b8ac99bbf36 /doc
parentff19e59a58940080f7df2bbdf46981e043aa6146 (diff)
downloadQt-6ff22762df68d60288cdc95b9359ca2544bd7bbe.zip
Qt-6ff22762df68d60288cdc95b9359ca2544bd7bbe.tar.gz
Qt-6ff22762df68d60288cdc95b9359ca2544bd7bbe.tar.bz2
Adding snippet code to coding article.
Task-number: QTBUG-16071
Diffstat (limited to 'doc')
-rw-r--r--doc/src/declarative/graphicaleffects.qdoc36
-rw-r--r--doc/src/howtos/qmlbestpractices/qmlbestpractices-coding.qdoc105
-rw-r--r--doc/src/snippets/declarative/bestpractices/group.qml75
3 files changed, 132 insertions, 84 deletions
diff --git a/doc/src/declarative/graphicaleffects.qdoc b/doc/src/declarative/graphicaleffects.qdoc
deleted file mode 100644
index b5ef601..0000000
--- a/doc/src/declarative/graphicaleffects.qdoc
+++ /dev/null
@@ -1,36 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Free Documentation License
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of this
-** file.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qmlgraphicaleffects.html
-\ingroup qml-features
-\contentspage QML Features
-\previouspage {QML Internationalization}{Internationalization}
-\nextpage {QML Features}
-\title QML Graphical Effects
-
-*/
diff --git a/doc/src/howtos/qmlbestpractices/qmlbestpractices-coding.qdoc b/doc/src/howtos/qmlbestpractices/qmlbestpractices-coding.qdoc
index 6c83c80..e33ee13 100644
--- a/doc/src/howtos/qmlbestpractices/qmlbestpractices-coding.qdoc
+++ b/doc/src/howtos/qmlbestpractices/qmlbestpractices-coding.qdoc
@@ -26,69 +26,78 @@
****************************************************************************/
/*!
- \page qml-best-practices-coding.html
- \ingroup qml-best-practices
- \contentspage QML Best Practices Guides
- \previouspage QML Best Practices Guides
- \startpage QML Best Practices Guides
- \title QML Best Practices: Coding Conventions
+\page qml-best-practices-coding.html
+\ingroup qml-best-practices
+\contentspage QML Best Practices Guides
+\previouspage QML Best Practices Guides
+\startpage QML Best Practices Guides
+\title QML Best Practices: Coding Conventions
- \brief QML Coding Conventions and Importing Files
+\brief QML Coding Conventions and Importing Files
- There are many different ways to code using QML. These are a set of
- guidelines to help your code look better and consistent.
+There are many different ways to code using QML. These are a set of
+guidelines to help your code look better and consistent.
- \section1 Coding Conventions
+\section1 Coding Conventions
- The official QML Coding Conventions may be found at
- \l {QML Coding Conventions}. This is the recommended convention that will be
- used throughout the QML documentation.
+The official QML Coding Conventions may be found at
+\l {QML Coding Conventions}. This is the recommended convention that will be
+used throughout the QML documentation.
- In addition, Qt's official code style may be found at the \l {Qt Coding Style}.
+In addition, Qt's official code style may be found at the \l {Qt Coding Style}.
- \section1 Importing Files into QML
+\section1 Importing Files into QML
- To import items such as directories, use the "import" keyword, similar to
- the way the \c {import QtQuick 1.0} statement is used.
+To import items such as directories, use the "import" keyword, similar to
+the way the \c {import QtQuick 1.0} statement is used.
- \qml
- import QtQuick 1.0
- import QtWebKit 1.0
- import "subdirectory"
- import "script.js"
- \endqml
+\qml
+import QtQuick 1.0
+import QtWebKit 1.0
+import "subdirectory"
+import "script.js"
+\endqml
- To facilitate the importation of QML components, it is best to begin the QML
- file with an uppercase character. This way, the user can simply declare the
- component using the file name as the component name. For example, if a QML
- component is in a file named \c Button.qml, then the user may import the
- component by declaring a \c {Button {}}. Note that this method only works if
- the QML files are in the same directory.
+To facilitate the importation of QML components, it is best to begin the QML
+file with an uppercase character. This way, the user can simply declare the
+component using the file name as the component name. For example, if a QML
+component is in a file named \c Button.qml, then the user may import the
+component by declaring a \c {Button {}}. Note that this method only works if
+the QML files are in the same directory.
- \qml
- import QtQuick 1.0
+It is also possible to import QML files which have file names that begin in
+lower case or files in a different directory by using a \c qmldir file.
- Rectangle {
- width: 50; height: 50
+A \c qmldir file tells your QML application which QML components, plugins,
+or directories to import. The \c qmldir file must reside in an imported
+directory. By using the \c qmldir file, users may import any QML file and assign any
+valid QML component name to the component.
- Button {} //Button is defined in Button.qml in the same directory
- }
- \endqml
+For more information, read the section on
+\l{qml-loading-components}{Loading a Component}.
- It is also possible to import QML files which have file names that begin in
- lower case or files in a different directory by using a \c qmldir file.
+\section1 Commenting Code
- A \c qmldir file tells your QML application which QML components, plugins,
- or directories to import. The \c qmldir file must reside in an imported
- directory.
+Commenting code allows others to read the source code better. As well, comments
+allow the programmer to think about his or her code; a confusing comment may
+mean the code is confusing.
- \code
- //A very simple qmldir file
+Similar to JavaScript or C++, there are two ways of commenting QML code:
+\list
+\o Single line comments start with \c{//} and finish at the end of the line
+\o Multiline comments start with \c{/*} and finish with *\/
+\endlist
- Button ./custom.qml //a QML component called Button in the file custom.qml
- plugin FilePlugin ./plugins //a plugin called FileDialog in the plugins directory
- \endcode
+\section1 Group Properties
+
+Many QML properties are \l{attached-properties}{attached} or
+\l {qml-grouped-properties}{group} properties. For convenience, you may treat
+them as another element when dealing with multiple properties belonging to the
+same group.
+
+\snippet doc/src/snippets/declarative/bestpractices/group.qml not grouped
+Treating groups of properties as a block can ease confusion and help relate the
+properties with other properties.
+\snippet doc/src/snippets/declarative/bestpractices/group.qml grouped
- By using the \c qmldir file, users may import any QML file and assign any
- valid QML component name to the component.
*/
diff --git a/doc/src/snippets/declarative/bestpractices/group.qml b/doc/src/snippets/declarative/bestpractices/group.qml
new file mode 100644
index 0000000..07243dc
--- /dev/null
+++ b/doc/src/snippets/declarative/bestpractices/group.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [document]
+import QtQuick 1.0
+
+//! [parent begin]
+Rectangle {
+//! [parent begin]
+ width: 175; height: 175; color: "white"
+
+Rectangle{
+width: 170; height: 170
+//! [not grouped]
+border.width: 1
+border.color: "red"
+anchors.bottom: parent.bottom
+anchors.left: parent.left
+//! [not grouped]
+}
+Rectangle {
+ width: 100; height: 100
+
+//! [grouped]
+border {
+ width: 1;
+ color: "red"
+}
+anchors {
+ bottom: parent.bottom;
+ left: parent.left
+}
+//! [grouped]
+}
+//! [parent end]
+}
+//! [parent end]
+//! [document]