diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-10-07 08:26:35 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-10-07 08:26:35 (GMT) |
commit | fdec8807127844c55fcc0bb43ad0ab7db1d81a07 (patch) | |
tree | f1643e784ab2561bc8e74d3b6ab9ad60d9e59019 /doc/src/declarative/tutorial1.qdoc | |
parent | 8a54ed9524befc4a172cdc19a18d9953f3a01df0 (diff) | |
parent | 68573410fb50d95a6ce27cd001d2e140b0b4aedd (diff) | |
download | Qt-fdec8807127844c55fcc0bb43ad0ab7db1d81a07.zip Qt-fdec8807127844c55fcc0bb43ad0ab7db1d81a07.tar.gz Qt-fdec8807127844c55fcc0bb43ad0ab7db1d81a07.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Conflicts:
doc/src/declarative/tutorial1.qdoc
doc/src/declarative/tutorial2.qdoc
doc/src/declarative/tutorial3.qdoc
Diffstat (limited to 'doc/src/declarative/tutorial1.qdoc')
-rw-r--r-- | doc/src/declarative/tutorial1.qdoc | 69 |
1 files changed, 24 insertions, 45 deletions
diff --git a/doc/src/declarative/tutorial1.qdoc b/doc/src/declarative/tutorial1.qdoc index e6232af..ad454f2 100644 --- a/doc/src/declarative/tutorial1.qdoc +++ b/doc/src/declarative/tutorial1.qdoc @@ -1,78 +1,57 @@ /*! \page tutorial1.html \target tutorial1 -\title Tutorial 1 - Hello World! +\title Tutorial 1 - Basic Types -This first program is a simple "Hello world" example. The picture below is a screenshot of this program. +This first program is a very simple "Hello world" example that introduces some basic QML concepts. +The picture below is a screenshot of this program. \image declarative-tutorial1.png Here is the QML code for the application: -\code -Rectangle { - id: Page - width: 480 - height: 200 - color: "LightGrey" - Text { - id: HelloText - text: "Hello world!" - font.pointSize: 24 - font.bold: true - y: 30 - anchors.horizontalCenter: Page.horizontalCenter - } -} -\endcode +\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 0 \section1 Walkthrough +\section2 Import + +First, we need to import the types that we need for this example. Most QML files will import the built-in QML +types (like \l{Rectangle}, \l{Image}, ...) that come with Qt with: + +\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 3 + \section2 Rectangle element -\code -Rectangle { - id: Page - width: 480 - height: 200 - color: "LightGrey" -} -\endcode +\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 1 -First, we declare a root element of type \l Rectangle. It is one of the basic building blocks you can use to create an application in QML. -We give it an id to be able to refer to it later. In this case, we call it \e Page. We also set the \c width, \c height and \c color properties. -The \l Rectangle element contains many other properties (such as \c x and \c y), but these are left at their default values. +We declare a root element of type \l{Rectangle}. It is one of the basic building blocks you can use to create an application in QML. +We give it an \c{id} to be able to refer to it later. In this case, we call it \e page. +We also set the \c width, \c height and \c color properties. +The \l{Rectangle} element contains many other properties (such as \c x and \c y), but these are left at their default values. \section2 Text element -\code -Text { - id: HelloText - text: "Hello world!" - font.pointSize: 24 - font.bold: true - y: 30 - anchors.horizontalCenter: Page.horizontalCenter -} -\endcode +\snippet examples/declarative/tutorials/helloworld/tutorial1.qml 2 -We add a text element as a child of our root element to display the text 'Hello world!'. +We add a \l Text element as a child of our root element that will display the text 'Hello world!'. The \c y property is used to position the text vertically at 30 pixels from the top of its parent. -The \c font.pointSize and \c font.bold properties are related to fonts and use the \e 'dot' notation. +The \c font.pointSize and \c font.bold properties are related to fonts and use the \l{Dot Properties}{dot notation}. -The \c anchors.horizontalCenter property refers to the horizontal center of an element. In this case, we specify that our text element should be horizontally centered in the \e Page element. +The \c anchors.horizontalCenter property refers to the horizontal center of an element. +In this case, we specify that our text element should be horizontally centered in the \e page element (see \l{anchor-layout}{Anchor-based Layout}). \section2 Viewing the example -To view what you have created, run the qmlviewer (located in the \c bin directory) with your filename as the first argument. For example, to run the provided completed Tutorial 1 example from the install location, you would type: +To view what you have created, run the qmlviewer (located in the \c bin directory) with your filename as the first argument. +For example, to run the provided completed Tutorial 1 example from the install location, you would type: \code -bin/qmlviewer $QTDIR/examples/declarative/tutorials/helloworld/t1/tutorial1.qml +bin/qmlviewer $QTDIR/examples/declarative/tutorials/helloworld/tutorial1.qml \endcode [\l tutorial] [Next: \l tutorial2] */ - |