source: trunk/doc/src/declarative/qml-intro.qdoc

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 26.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at [email protected].
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28
29
30/*!
31\page qml-intro.html
32\title Intro to Qt Quick
33
34\section1 Overview
35
36QML is a high level, scripted language. Its commands, more correctly \e elements,
37leverage the power and efficiency of the Qt libraries to make easy to use
38commands that perform intuitive functions. Draw a rectangle, display an image at
39a position and so on. Behind these elements are complex C++ libraries that
40efficiently perform the action. As with any graphical application, always
41consider that this ability to easily build graphically rich applications means
42that some care may be needed to prevent performance problems.
43
44The language also allows more flexibility of these commands by using
45Javascript rather than C++ to add new layers of logic to your application.
46Javascript is easier to learn than C++ and can be embedded into the QML
47files or imported from a separate file.
48
49\bold{In QML the types of various 'objects' are referred to as \l {QML
50Elements}{elements}}.
51
52An element usually has various \e properties that help define the element. For
53example, if we created an element called Circle then the radius of the circle
54would be a property.
55
56
57\section1 A First Look
58
59The basic syntax of an \l{QML Elements}{element} is
60
61\qml
62SomeElement {
63 id: myObject
64 ... some other things here ...
65}
66\endqml
67
68Here we are defining a new object. We specify its 'type' first as SomeElement.
69Then within matching braces { ... } we specify the various parts of our
70element.
71
72The \c id is a unique identifier for the element, it must start with a lower
73case letter and only contain letters, numbers and underscores. It is this
74particular object's name. If this SomeElement \l {QML Elements}{element} was
75a Rectangle instead and it was one of many then the \e optional unique id
76would allow us to manipulate each element individually.
77
78Each visual element is ultimately based on, or inherits from, an element
79called \l Item. \l Item has certain properties and actions that may be
80useful. The properties have default values so you need only specify the
81ones you will need.
82
83Take a simple element such as a \l Rectangle. It has an \c id, we will call
84it \e myRectangle, it has a \c width and a \c height. Imagine that we
85want a rectangle that is 500 pixels by 400 pixels in the x and y directions
86(horizontal by vertical).