diff options
author | David Boddie <dboddie@trolltech.com> | 2010-08-13 12:04:29 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2010-08-13 12:04:29 (GMT) |
commit | 7d805a6717692b540c02b8caace25a0b47c7f0d6 (patch) | |
tree | 3368927682df73ac437e8f321ba28e51d1463cd0 /doc/src/declarative | |
parent | c6ed32dc7e9c8a566f376d1baa7e616a1019f9af (diff) | |
parent | 58d0e46dcc50a3cddabc177c9dfdfec5c66e932d (diff) | |
download | Qt-7d805a6717692b540c02b8caace25a0b47c7f0d6.zip Qt-7d805a6717692b540c02b8caace25a0b47c7f0d6.tar.gz Qt-7d805a6717692b540c02b8caace25a0b47c7f0d6.tar.bz2 |
Merge branch '4.7' of ../oslo-staging-2 into 4.7
Conflicts:
doc/src/declarative/declarativeui.qdoc
doc/src/examples/simpletreemodel.qdoc
doc/src/examples/spinboxdelegate.qdoc
doc/src/getting-started/demos.qdoc
doc/src/getting-started/gettingstartedqml.qdoc
doc/src/index.qdoc
src/declarative/qml/qdeclarativeimageprovider.cpp
Diffstat (limited to 'doc/src/declarative')
-rw-r--r-- | doc/src/declarative/declarativeui.qdoc | 100 | ||||
-rw-r--r-- | doc/src/declarative/dynamicobjects.qdoc | 2 | ||||
-rw-r--r-- | doc/src/declarative/elements.qdoc | 6 | ||||
-rw-r--r-- | doc/src/declarative/qml-intro.qdoc | 414 | ||||
-rw-r--r-- | doc/src/declarative/qtdeclarative.qdoc | 2 | ||||
-rw-r--r-- | doc/src/declarative/qtprogrammers.qdoc | 3 |
6 files changed, 95 insertions, 432 deletions
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index b25d000..ed8b734 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -27,13 +27,13 @@ /*! \title Qt Quick -\page declarativeui.html +\page qtquick.html \brief Qt Quick provides a declarative framework for building highly dynamic, custom user interfaces. Qt Quick provides a declarative framework for building highly dynamic, -custom user interfaces from a rich set of \l {QML Elements}{QML elements}. +custom user interfaces from a rich set of \l{QML Elements}{QML elements}. Qt Quick helps programmers and designers collaborate to build the fluid user interfaces that are becoming common in portable consumer devices, such as mobile phones, media players, set-top boxes @@ -41,72 +41,74 @@ and netbooks. Qt Quick consists of the QtDeclarative C++ module, QML, and the integration of both of these into the Qt Creator IDE. Using the QtDeclarative C++ module, you can load and interact with QML files from your Qt application. -QML provides mechanisms to declaratively build an object tree using -\l {QML Elements}{QML elements}. QML improves the integration between -\l {http://www.ecma-international.org/publications/standards/Ecma-262.htm}{JavaScript} -and Qt's existing QObject based type -system, adds support for automatic \l {Property Binding}{property -bindings} and provides \l {Network Transparency}{network transparency} -at the language level. +QML is an extension to \l{About JavaScript}{JavaScript}, that provides +a mechanism to declaratively build an object tree of +\l{QML Elements}{QML elements}. QML improves the integration between +JavaScript and Qt's existing QObject-based type system, adds support for +automatic \l{Property Binding}{property bindings} and provides +\l{Network Transparency}{network transparency} at the language level. -The \l {QML Elements}{QML elements} are a sophisticated set of +The \l{QML Elements}{QML elements} are a sophisticated set of graphical and behavioral building blocks. These different elements -are combined together in \l {QML Documents}{QML documents} to build +are combined together in \l{QML Documents}{QML documents} to build components ranging in complexity from simple buttons and sliders, to -complete internet-enabled applications like a \l -{http://www.flickr.com}{Flickr} photo browser. +complete Internet-enabled applications like a photo browser for the +popular \l{http://www.flickr.com}{Flickr} photo-sharing site. -Qt Quick builds on \l {QML for Qt programmers}{Qt's existing -strengths}. QML can be be used to incrementally extend an existing -application or to build completely new applications. QML is fully \l -{Extending QML in C++}{extensible from C++} through the QtDeclarative Module. +Qt Quick builds on \l{QML for Qt programmers}{Qt's existing strengths}. +QML can be be used to incrementally extend an existing application or +to build completely new applications. QML is fully +\l{Extending QML in C++}{extensible from C++} through the QtDeclarative +Module. \section1 Getting Started \list -\o \l {Introduction to the QML language} -\o \l {QML Tutorial}{Tutorial: 'Hello World'} -\o \l {QML Advanced Tutorial}{Tutorial: 'Same Game'} -\o \l {QML Examples and Demos} -\o \l {QML for Qt programmers} +\o \l{Introduction to the QML language} +\o \l{QML Tutorial}{Tutorial: 'Hello World'} +\o \l{QML Advanced Tutorial}{Tutorial: 'Same Game'} +\o \l{QML Examples and Demos} +\o \l{QML for Qt Programmers} +\o \l{Getting Started Programming with QML} +\o \l{Beginning Qt Quick} \endlist \section1 Core QML Features \list -\o \l {QML Documents} -\o \l {Property Binding} -\o \l {Network Transparency} -\o \l {QML Scope} -\o \l {Integrating JavaScript} -\o \l {Data Models} -\o \l {anchor-layout.html}{Anchor-based Layout} -\o \l {qdeclarativestates.html}{States} -\o \l {qdeclarativeanimation.html}{Animation} -\o \l {qdeclarativefocus.html}{Keyboard Focus} -\o \l {qdeclarativemodules.html}{Modules} -\o \l {Extending types from QML} -\o \l {qdeclarativedynamicobjects.html}{Dynamic Object Creation} +\o \l{QML Documents} +\o \l{Property Binding} +\o \l{Network Transparency} +\o \l{QML Scope} +\o \l{Integrating JavaScript} +\o \l{Data Models} +\o \l{Anchor-based Layout in QML} +\o \l{QML States} +\o \l{QML Animation} +\o \l{Keyboard Focus in QML} +\o \l{QML Modules} +\o \l{Extending types from QML} +\o \l{Dynamic Object Management in QML} +\o \l{Qt Declarative UI Runtime} \endlist \section1 Using QML with C++ \list -\o \l {qmlruntime.html}{The Qt Declarative Runtime} -\o \l {Using QML in C++ Applications} -\o \l {Integrating QML with existing Qt UI code} -\o \l {Tutorial: Writing QML extensions with C++} -\o \l {Extending QML in C++} +\o \l{Using QML in C++ Applications} +\o \l{Integrating QML with existing Qt UI code} +\o \l{Tutorial: Writing QML extensions with C++} +\o \l{Extending QML in C++} \endlist \section1 Reference \list -\o \l {QML Elements} -\o \l {QML Global Object} -\o \l {QML Internationalization} -\o \l {QML Security} -\o \l {QtDeclarative Module} -\o \l {Debugging QML} -\o \l {QML Viewer} -\o \l {QML Performance} -\o \l {QML Coding Conventions} +\o \l{QML Elements} +\o \l{QML Global Object} +\o \l{QML Internationalization} +\o \l{QML Security} +\o \l{QtDeclarative Module} +\o \l{Debugging QML} +\o \l{QML Viewer} +\o \l{QML Performance} +\o \l{QML Coding Conventions} \endlist */ diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc index 997f601..e735bce 100644 --- a/doc/src/declarative/dynamicobjects.qdoc +++ b/doc/src/declarative/dynamicobjects.qdoc @@ -27,7 +27,7 @@ /*! \page qdeclarativedynamicobjects.html -\title Dynamic Object Management +\title Dynamic Object Management in QML QML provides a number of ways to dynamically create and manage QML objects. The \l{Loader}, \l{Repeater}, \l{ListView}, \l{GridView} and \l{PathView} elements diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index c2930b3..55b71e1 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -26,11 +26,11 @@ ****************************************************************************/ /*! -\page qdeclarativeelements.html +\page qmlelements.html \target elements \title QML Elements -The following table lists the QML elements provided by the \l {QtDeclarative}{Qt Declarative} module. +The following table lists the QML elements provided by the \l{QtDeclarative} module. \table \header \o {2,1} \bold {Basic Visual Items} @@ -54,7 +54,7 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt \row \o \l {Flickable} \o Provides a surface that can be "flicked" \row \o \l {Flipable} \o Provides a surface that produces flipping effects \row \o \l {GestureArea} (experimental) \o Enables simple gesture handling - + \header \o {2,1} \bold {States} \row \o \l {State} \o Defines sets of configurations of objects and properties \row \o \l {PropertyChanges} \o Describes property changes within a state diff --git a/doc/src/declarative/qml-intro.qdoc b/doc/src/declarative/qml-intro.qdoc index fbab001..69dd500 100644 --- a/doc/src/declarative/qml-intro.qdoc +++ b/doc/src/declarative/qml-intro.qdoc @@ -28,14 +28,11 @@ /*! - -\page qml-intro.html +\page qml-intro.html \title Beginning Qt Quick - \section1 Overview - QML is a high level, scripted language. Its commands, more correctly \e elements, leverage the power and efficiency of the Qt libraries to make easy to use commands that perform intuitive functions. Draw a rectangle, display an image at @@ -61,12 +58,7 @@ would be a property. The basic syntax of an \l {QML Elements}{element} is - \code - SomeElement { - id: myObject - ... some other things here ... - } - \endcode +\snippet doc/src/snippets/declarative/qml-intro/basic-syntax.qml basic syntax Here we are defining a new object. We specify its 'type' first as SomeElement. Then within matching braces { ... } we specify the various parts of our @@ -90,61 +82,38 @@ want a rectangle that is 500 pixels by 400 pixels in the x and y directions We can implement this \l Rectangle with these properties this way - \code - import Qt 4.7 - - // This is a comment. And below myRectangle is defined. - Rectangle { - id: myRectangle - width: 500 - height: 400 - } - \endcode +\quotefile doc/src/snippets/declarative/qml-intro/rectangle.qml This is a valid QML script. To run it, copy it and save it to a file, say -myexample.qml, and on the command line run the command +myexample.qml, and on the command line run the following command: - \code - qmlviewer myexample.qml - \endcode +\code +qmlviewer myexample.qml +\endcode On Mac OS X, open the "QMLViewer" application instead and open the \c myexample.qml file, or run it from the command line: - \code - QMLViewer.app/Contents/MacOS/QMLViewer myexample.qml - \endcode - +\code +QMLViewer.app/Contents/MacOS/QMLViewer myexample.qml +\endcode It will create a very boring rectangle in its own window. - \section1 Hello World! We can now add some color and text to make a Hello World QML program. -\l Rectangle has the property \l {Rectangle::color}{color} to produce a +\l Rectangle has the property \l{Rectangle::color}{color} to produce a background color. Text is handled by a different element called \l Text. We need to create a -\l Text object inside the \l Rectangle and set its \l {Text::text}{text} -property to "Hello World!". So to set the text to 'Hello world' and the +\l Text object inside the \l Rectangle and set its \l{Text::}{text} +property to "Hello World!". So to set the text to "Hello world" and the background colour to light gray, - \code - import Qt 4.7 - - Rectangle { - id: myRectangle - width: 500 - height: 400 - - Text { text: "Hello World!" } - - color: "lightgray" - } - \endcode +\quotefile doc/src/snippets/declarative/qml-intro/hello-world1.qml \section1 Hello World Again @@ -158,12 +127,7 @@ position belongs to the \l Text element so we set the position inside its definition. Note that we separate different QML statements on the same line with a semi-colon, or we could have simply put each statement on a new line - \code - Text { - text: "<h2>Hello World</h2>"; color: "darkgreen" - x: 100; y:100 - } - \endcode +\snippet doc/src/snippets/declarative/qml-intro/hello-world2.qml updated text Not only did we reposition the text, but the text was altered by adding HTML tags to change the font size. The text color was also changed from the @@ -174,13 +138,7 @@ We could also have used a hexadecimal string for the RGB (red-green-blue, as #rrggbb) values of the color similar to the method used in HTML. For example, mostly blue with a green tint, - \code - Text { - text: "<h1>Hello world again</h1>" - color: "#002288" - x: 100; y: 100 - } - \endcode +\snippet doc/src/snippets/declarative/qml-intro/hello-world3.qml updated text All of these changes occurred within the \l Text object which is the scope of these property changes. @@ -198,11 +156,7 @@ source of the image, the path to the file, is a URL. Therefore the file can be local: \e {mydir/myimage1.png}. Or it can be remote: \e {"http://www.example.com/images/myimage1.png"}. - \code - Image { - source: "images/qt-logo.png" - } - \endcode +\snippet doc/src/snippets/declarative/qml-intro/hello-world4.qml added an image This displays the image, as we would expect, at the top left of the window. The position of the default x = 0, y = 0 coordinate. The example here uses @@ -213,44 +167,12 @@ Let us reposition the image and enlarge it. Place it at the same 'x' offset as the "Hello world again" text, but put it another 50 pixels below the text, also make it 150 by 150 pixels in size, - \code - Image { - source: "images/qt-logo.png" - x: 100; y: 150 - width: 150; height: 150 - } - \endcode +\snippet doc/src/snippets/declarative/qml-intro/hello-world5.qml positioning the image Adding the Hello World example, with the text and the image example we can write a simple piece of QML that starts to look a bit better. - \code - import Qt 4.7 - - Rectangle { - id: myRectangle - width: 500 - height: 400 - - // A light gray background - color: "lightgray" - - // Position and color some text - Text { - text: "<h1>Hello world again</h1>" - color: "darkgreen" - x: 100; y: 100 - } - - // Using the opportunity to resize the image. - Image { - source: "images/qt-logo.png" - x: 100; y: 150 - width: 150; height: 150 - } - - } - \endcode +\quotefile doc/src/snippets/declarative/qml-intro/hello-world5.qml The result is still quite simple @@ -281,22 +203,7 @@ If we want to position an image at the bottom of the rectangle it is inside. I have to specify that the bottom of the image is also at the bottom of the rectangle - \code - import Qt 4.7 - - Rectangle { - id: myWin - width: 500 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.png" - width: 150; height: 150 - anchors.bottom: myWin.bottom - } - } - \endcode +\quotefile doc/src/snippets/declarative/qml-intro/anchors1.qml This places the logo at the bottom left of the window. @@ -315,25 +222,7 @@ the bottomMargin property is used. So the new actions for the script are Encoded into QML the script becomes - \code - import Qt 4.7 - - Rectangle { - id: myWin - width: 500 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.png" - width: 150; height: 150 - anchors.bottom: myWin.bottom - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 10 - } - } - \endcode - +\quotefile doc/src/snippets/declarative/qml-intro/anchors2.qml Run this and resize the window. You will see that now the position of the image adjusts during the resize. @@ -344,14 +233,7 @@ You can also add another object say a block of descriptive text and place it above or below the image or to the side. This code places some text just above the image - \code - Text { - text: "<h2>The Qt Logo</h2>" - anchors.bottom: image1.top - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 15 - } - \endcode +\snippet doc/src/snippets/declarative/qml-intro/anchors3.qml adding some text \image qml-intro-anchors3.png @@ -359,17 +241,15 @@ above the image referencing these properties from another object we use the property directly, instead of saying: - \code - myRectangle.anchors.top // Wrong - \endcode +\qml +myRectangle.anchors.top // Wrong +\endqml we use - \code - myRectangle.top // Correct - \endcode - - +\qml +myRectangle.top // Correct +\endqml \section1 Transformations @@ -391,9 +271,9 @@ Rotation of text was also suggested. It could also be useful to scale the text. We can do both. The \l {Item::transform}{transform} property is a \e list of \l Transform elements, so using the list syntax - \code - myList: [ listElement1, listElement2, ... } ] - \endcode +\qml +myList: [ listElement1, listElement2, ... } ] +\endqml we can produce a list of transformations. @@ -402,46 +282,7 @@ vertically by a factor of 1.5 and by 1.2 horizontally. Using the example above as the basis for this we have, - \code - import Qt 4.7 - - Rectangle { - id: myWin - width: 500 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.png" - width: 150; height: 150 - anchors.bottom: myWin.bottom - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 10 - - transform: Rotation { - origin.x: 75; origin.y: 75 - axis{ x: 0; y: 0; z:1 } angle: -90 - } - - } - - Text { - text: "<h2>The Qt Logo -- taking it easy</h2>" - anchors.bottom: image1.top - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 15 - - transform: [ - Scale { xScale: 1.5; yScale: 1.2 } , - - Rotation { - origin.x: 75; origin.y: 75 - axis{ x: 0; y: 0; z:1 } angle: -45 - } - ] - } - } - \endcode +\quotefile doc/src/snippets/declarative/qml-intro/transformations1.qml The code block in \c image1 starting with \c transform specifies that the \l {Item::transform}{transform} property will be a Rotation through -90 @@ -479,30 +320,7 @@ from \l Item. The rotation property is a real number that specifies the angle in a clockwise direction for the rotation of the object. Here is the code for our animated rotating image. - \code - import Qt 4.7 - - Rectangle { - id: mainRec - width: 600 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.png" - x: 200; y: 100 - width: 100; height: 100 - - // Animate a rotation - transformOrigin: Item.Center - NumberAnimation on rotation { - from: 0; to: 360 - duration: 2000 - loops: Animation.Infinite - } - } - } - \endcode +\quotefile doc/src/snippets/declarative/number-animation1.qml The \c {transformOrigin: Item.Center} is redundant since this is the default axis of rotation anyway. But if you change \c Center to \c BottomRight you @@ -515,32 +333,7 @@ combination. For example, if the task had been to animate the rotation about the y-axis passing through the center of the image then the following code would do it. - \code - import Qt 4.7 - - Rectangle { - id: mainRec - width: 600 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.png" - x: 200; y: 100 - width: 100; height: 100 - - // Animate a rotation - transform: Rotation { - origin.x: 50; origin.y: 50; axis {x:0; y:1; z:0} angle:0 - NumberAnimation on angle { - from: 0; to: 360; - duration: 3000; - loops: Animation.Infinite - } - } - } - } - \endcode +\quotefile doc/src/snippets/declarative/number-animation2.qml Here there is a rectangle 600 by 400 pixels. Placed within that rectangle is an image 100 by 100 pixels. It is rotated about the center of the image @@ -569,31 +362,7 @@ will be animating the position and the size of the image. First create two images - \code - import Qt 4.7 - - Rectangle { - id: mainRec - width: 600 - height: 400 - z: 0 - - Image { - id: image1 - source: "images/qt-logo.png" - x: 20; y: 20 ; z: 1 - width: 100; height: 100 - } - - Image { - id: image2 - source: "images/qt-logo.png" - width: 100; height: 100 - x: (mainRec.width - 100)/2; y: (mainRec.height - 100)/2 - z: 2 - } - } - \endcode +\quotefile doc/src/snippets/declarative/sequential-animation1.qml We will add to 'image1' a SequentialAnimation from x = 20 to the target of x = 450. The 'from' values will be used because we will be repeating the @@ -606,14 +375,7 @@ between the x values and over a given duration. After the NumberAnimation there will be a PauseAnimation that will pause the animation for 500 milliseconds (half a second) simply for the visual effect. - \code - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { from: 20; to: 450; easing.type: "InOutQuad"; -duration: 2000 } - PauseAnimation { duration: 500 } - } - \endcode +\snippet doc/src/snippets/declarative/sequential-animation2.qml adding a sequential animation A similar block of code is written for the animation of the 'y' value of the position. @@ -628,54 +390,7 @@ and image1 to 1 and image2 to 2 then image2 will be in the foreground and image1 in the background. When image1 passes image2 it will pass behind it. The completed code looks like - \code - Rectangle { - id: mainRec - width: 600 - height: 400 - z: 0 - - Image { - id: image2 - source: "images/qt-logo.png" - width: 100; height: 100 - x: (mainRec.width - 100)/2; y: (mainRec.height - 100)/2 - z: 2 - } - - Image { - id: image1 - source: "images/qt-logo.png" - x: 20; y: 20 ; z: 1 - width: 100; height: 100 - - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { - from: 20; to: 450 - easing.type: "InOutQuad"; duration: 2000 - } - PauseAnimation { duration: 500 } - } - - SequentialAnimation on y { - loops: Animation.Infinite - NumberAnimation { - from: 20; to: 250 - easing.type: "InOutQuad"; duration: 2000 - } - PauseAnimation { duration: 500 } - } - - SequentialAnimation on scale { - loops: Animation.Infinite - NumberAnimation { from: 1; to: 0.5; duration: 1000 } - NumberAnimation { from: 0.5; to: 1; duration: 1000 } - PauseAnimation { duration: 500 } - } - } - } - \endcode +\quotefile doc/src/snippets/declarative/sequential-animation3.qml The \c {easing.type} has many options, expressed as a string. It specifies the kind of equation that describes the acceleration of the property value, not @@ -756,60 +471,7 @@ will be the default state. We will just go to 'night' by clicking and holding the left mouse button down, releasing the mouse button will reverse the process - \code - import Qt 4.7 - - Rectangle { - id: mainRectangle - width: 600 - height: 400 - color: "black" - - Rectangle { - id: sky - width: 600 - height: 200 - y: 0 - color: "lightblue" - } - - Rectangle { - id: ground - width: 600; height: 200 - y: 200 - color: "green" - } - - MouseArea { - id: mousearea - anchors.fill: mainRectangle - } - - states: [ State { - name: "night" - when: mousearea.pressed == true - PropertyChanges { target: sky; color: "darkblue" } - PropertyChanges { target: ground; color: "black" } - }, - State { - name: "daylight" - when: mousearea.pressed == false - PropertyChanges { target: sky; color: "lightblue" } - PropertyChanges { target: ground; color: "green" } - } - ] - - transitions: [ Transition { - from: "daylight"; to: "night" - ColorAnimation { duration: 1000 } - }, - Transition { - from: "night"; to: "daylight" - ColorAnimation { duration: 500 } - } - ] - } - \endcode +\quotefile doc/src/snippets/declarative/states1.qml Several new things appear in this sample. Firstly, we use a \l MouseArea element to detect mouse clicks in the \e mainRectangle. Secondly, we use diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc index 413eb59..b4f4c83 100644 --- a/doc/src/declarative/qtdeclarative.qdoc +++ b/doc/src/declarative/qtdeclarative.qdoc @@ -48,7 +48,7 @@ \endcode For more information on the Qt Declarative module, see the - \l{declarativeui.html}{Qt Quick} documentation. + \l{Qt Quick} documentation. */ diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc index 68d56bf..c0639db 100644 --- a/doc/src/declarative/qtprogrammers.qdoc +++ b/doc/src/declarative/qtprogrammers.qdoc @@ -26,10 +26,9 @@ ****************************************************************************/ /*! - \page qtprogrammers.html \target qtprogrammers -\title QML for Qt programmers +\title QML for Qt Programmers \section1 Overview |