diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2012-07-19 11:05:05 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-08 10:50:52 +0200 |
commit | 3704f1f0b25aee9e7c903368202ccf7dc16d9107 (patch) | |
tree | c44762ec24a0a351f401bdf1f4e43c7dde18c396 /src/quick/doc/snippets | |
parent | 6ebf215fdaf2d757ab90ae4d46c4b938e978e2dc (diff) |
Provide features/use-case docs in QML AppDevGuide
The most common use-cases should have easily-accessible solutions
available from the front-page of the QML application developer guide.
This commit adds that documentation.
Task-number: QTBUG-26428
Change-Id: Id15e76db15fbe3599e9ac5dd98e74ad4e034ece4
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'src/quick/doc/snippets')
16 files changed, 1322 insertions, 0 deletions
diff --git a/src/quick/doc/snippets/qml/usecases/Button.qml b/src/quick/doc/snippets/qml/usecases/Button.qml new file mode 100644 index 0000000000..a6934cfa0a --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/Button.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Rectangle { + id: container + // The caption property is an alias to the text of the Text element, so Button users can set the text + property alias caption: txt.text + // The clicked signal is emitted whenever the button is clicked, so Button users can respond + signal clicked + + // The button is set to have rounded corners and a thin black border + radius: 4 + border.width: 1 + // This button has a fixed size, but it could resize based on the text + width: 160 + height: 40 + + // A SystemPalette is used to get colors from the system settings for the background + SystemPalette { id: sysPalette } + + gradient: Gradient { + + // The top gradient is darker when 'pressed', all colors come from the system palette + GradientStop { position: 0.0; color: ma.pressed ? sysPalette.dark : sysPalette.light } + + GradientStop { position: 1.0; color: sysPalette.button } + } + + Text { + id: txt + // This is the default value of the text, but most Button users will set their own with the caption property + text: "Button" + font.bold: true + font.pixelSize: 16 + anchors.centerIn: parent + } + + MouseArea { + id: ma + anchors.fill: parent + // This re-emits the clicked signal on the root item, so that Button users can respond to it + onClicked: container.clicked() + } +} + +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/MyText.qml b/src/quick/doc/snippets/qml/usecases/MyText.qml new file mode 100644 index 0000000000..5d9310dda5 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/MyText.qml @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Text { + color: "lightsteelblue" + font { family: 'Courier'; pixelSize: 20; bold: true; capitalization: Font.SmallCaps } +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/animations.qml b/src/quick/doc/snippets/qml/usecases/animations.qml new file mode 100644 index 0000000000..486cf57b1e --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/animations.qml @@ -0,0 +1,187 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + + width: 320 + height: 480 + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + Column { + //![states] + + Item { + id: container + width: 320 + height: 120 + + Rectangle { + id: rect + color: "red" + width: 120 + height: 120 + + MouseArea { + anchors.fill: parent + onClicked: container.state == 'other' ? container.state = '' : container.state = 'other' + } + } + states: [ + // This adds a second state to the container where the rectangle is farther to the right + + State { name: "other" + + PropertyChanges { + target: rect + x: 200 + } + } + ] + transitions: [ + // This adds a transition that defaults to applying to all state changes + + Transition { + + // This applies a default NumberAnimation to any changes a state change makes to x or y properties + NumberAnimation { properties: "x,y" } + } + ] + } + //![states] + //![behave] + Item { + width: 320 + height: 120 + + Rectangle { + color: "green" + width: 120 + height: 120 + + // This is the behavior, and it applies a NumberAnimation to any attempt to set the x property + Behavior on x { + + NumberAnimation { + //This specifies how long the animation takes + duration: 600 + //This selects an easing curve to interpolate with, the default is Easing.Linear + easing.type: Easing.OutBounce + } + } + + MouseArea { + anchors.fill: parent + onClicked: parent.x == 0 ? parent.x = 200 : parent.x = 0 + } + } + } + //![behave] + //![constant] + Item { + width: 320 + height: 120 + + Rectangle { + color: "blue" + width: 120 + height: 120 + + // By setting this SequentialAnimation on x, it and animations within it will automatically animate + // the x property of this element + SequentialAnimation on x { + id: xAnim + // Animations on properties start running by default + running: false + loops: Animation.Infinite // The animation is set to loop indefinitely + NumberAnimation { from: 0; to: 200; duration: 500; easing.type: Easing.InOutQuad } + NumberAnimation { from: 200; to: 0; duration: 500; easing.type: Easing.InOutQuad } + PauseAnimation { duration: 250 } // This puts a bit of time between the loop + } + + MouseArea { + anchors.fill: parent + // The animation starts running when you click within the rectangle + onClicked: xAnim.running = true + } + } + } + //![constant] + + //![scripted] + Item { + width: 320 + height: 120 + + Rectangle { + id: rectangle + color: "yellow" + width: 120 + height: 120 + + MouseArea { + anchors.fill: parent + // The animation starts running when you click within the rectange + onClicked: anim.running = true; + } + } + + // This animation specifically targets the Rectangle's properties to animate + SequentialAnimation { + id: anim + // Animations on their own are not running by default + // The default number of loops is one, restart the animation to see it again + + NumberAnimation { target: rectangle; property: "x"; from: 0; to: 200; duration: 500 } + + NumberAnimation { target: rectangle; property: "x"; from: 200; to: 0; duration: 500 } + } + } + //![scripted] + } +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/integratingjs-inline.qml b/src/quick/doc/snippets/qml/usecases/integratingjs-inline.qml new file mode 100644 index 0000000000..f9a7294109 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/integratingjs-inline.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: container + width: 320 + height: 480 + + function randomNumber() { + return Math.random() * 360; + } + + function getNumber() { + return container.randomNumber(); + } + + MouseArea { + anchors.fill: parent + // This line uses the JS function from the item + onClicked: rectangle.rotation = container.getNumber(); + } + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + Rectangle { + id: rectangle + anchors.centerIn: parent + width: 160 + height: 160 + color: "green" + Behavior on rotation { RotationAnimation { direction: RotationAnimation.Clockwise } } + } + +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/integratingjs.qml b/src/quick/doc/snippets/qml/usecases/integratingjs.qml new file mode 100644 index 0000000000..cf1a319b66 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/integratingjs.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 +import "myscript.js" as Logic + +Item { + width: 320 + height: 480 + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + MouseArea { + anchors.fill: parent + // This line uses the JS function from the separate JS file + onClicked: rectangle.rotation = Logic.getRandom(rectangle.rotation); + } + + Rectangle { + id: rectangle + anchors.centerIn: parent + width: 160 + height: 160 + color: "green" + Behavior on rotation { RotationAnimation { direction: RotationAnimation.Clockwise } } + } + +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/layouts.qml b/src/quick/doc/snippets/qml/usecases/layouts.qml new file mode 100644 index 0000000000..0099cdf319 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/layouts.qml @@ -0,0 +1,122 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + Rectangle { + // Manually positioned at 20,20 + x: 20 + y: 20 + width: 80 + height: 80 + color: "red" + } + Rectangle { + // Anchored to 20px off the top right corner of the parent + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 20 // Sets all margins at once + width: 80 + height: 80 + color: "blue" + } + Rectangle { + // Anchored to 20px off the top center corner of the parent + // Note the different group property syntax to the previous Rectangle. Both are valid. + anchors { horizontalCenter: parent.horizontalCenter; top: parent.top; topMargin: 20 } + width: 80 + height: 80 + color: "green" + } + + Row { // Lays the Rectangles out in a line + x: 20 + y: 120 + spacing: 20 // Places 20px of space between items + Rectangle { width: 80; height: 80; color: "red" } + Rectangle { width: 80; height: 80; color: "green" } + Rectangle { width: 80; height: 80; color: "blue" } + } + + Rectangle { + id: middleRect + //This Rectangle has its y animated, for the others to follow + x: 120 + y: 220 + SequentialAnimation on y { + loops: -1 + NumberAnimation { from: 220; to: 380; easing.type: Easing.InOutQuad; duration: 1200 } + NumberAnimation { from: 380; to: 220; easing.type: Easing.InOutQuad; duration: 1200 } + } + width: 80 + height: 80 + color: "green" + } + Rectangle { + // x,y bound to the position of middleRect + x: middleRect.x - 100 + y: middleRect.y + width: 80 + height: 80 + color: "red" + } + + Rectangle { + // Anchored to the position of middleRect + anchors.left: middleRect.right + anchors.leftMargin: 20 + anchors.verticalCenter: middleRect.verticalCenter + width: 80 + height: 80 + color: "blue" + } +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/myscript.js b/src/quick/doc/snippets/qml/usecases/myscript.js new file mode 100644 index 0000000000..037cd94c5a --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/myscript.js @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +// myscript.js +function getRandom(previousValue) { + return Math.floor(previousValue + Math.random() * 90) % 360; +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/styling-text.qml b/src/quick/doc/snippets/qml/usecases/styling-text.qml new file mode 100644 index 0000000000..719bfda3e0 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/styling-text.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: root + width: 480 + height: 320 + + Rectangle { + color: "#272822" + width: 480 + height: 320 + } + +//![texts] + Column { + spacing: 20 + + MyText { text: 'I am the very model of a modern major general!' } + + MyText { text: 'I\'ve information vegetable, animal and mineral.' } + + MyText { + width: root.width + wrapMode: Text.WordWrap + text: 'I know the kings of England and I quote the fights historical:' + } + + MyText { text: 'From Marathon to Waterloo in order categorical.' } + } +//![texts] +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/styling.qml b/src/quick/doc/snippets/qml/usecases/styling.qml new file mode 100644 index 0000000000..99212b5bd7 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/styling.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + width: 320 + height: 480 + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + Column { + width: childrenRect.width + anchors.centerIn: parent + spacing: 8 + // Each of these is a Button as styled in Button.qml + Button { caption: "Eeny"; onClicked: console.log("Eeny");} + Button { caption: "Meeny"; onClicked: console.log("Meeny");} + Button { caption: "Miny"; onClicked: console.log("Miny");} + Button { caption: "Mo"; onClicked: console.log("Mo");} + } +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/text.qml b/src/quick/doc/snippets/qml/usecases/text.qml new file mode 100644 index 0000000000..545be70e51 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/text.qml @@ -0,0 +1,105 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: root + width: 480 + height: 320 + + Rectangle { + color: "#272822" + width: 480 + height: 320 + } + + Column { + spacing: 20 + + Text { + text: 'I am the very model of a modern major general!' + + // color can be set on the entire element with this property + color: "yellow" + + } + + Text { + // For text to wrap, a width has to be explicitly provided + width: root.width + + // This setting makes the text wrap at word boundaries when it goes past the width of the Text object + wrapMode: Text.WordWrap + + // You can use \ to escape quotation marks, or to add new lines (\n). Use \\ to get a \ in the string + text: 'I am the very model of a modern major general. I\'ve information vegetable, animal and mineral. I know the kings of england and I quote the fights historical; from Marathon to Waterloo in order categorical.' + + // color can be set on the entire element with this property + color: "white" + + } + + Text { + text: 'I am the very model of a modern major general!' + + // color can be set on the entire element with this property + color: "yellow" + + // font properties can be set effciently on the whole string at once + font { family: 'Courier'; pixelSize: 20; italic: true; capitalization: Font.SmallCaps } + + } + + Text { + // HTML like markup can also be used + text: '<font color="white">I am the <b>very</b> model of a modern <i>major general</i>!</font>' + + // This could also be written font { pointSize: 14 }. Both syntaxes are valid. + font.pointSize: 14 + + // StyledText format supports fewer tags, but is more efficient than RichText + textFormat: Text.StyledText + + } + } +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/userinput-keys.qml b/src/quick/doc/snippets/qml/usecases/userinput-keys.qml new file mode 100644 index 0000000000..77e7524e4a --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/userinput-keys.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: root + + width: 320 + height: 480 + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + Rectangle { + id: rectangle + x: 40 + y: 20 + width: 120 + height: 120 + color: "red" + + focus: true + Keys.onUpPressed: rectangle.y -= 10 + Keys.onDownPressed: rectangle.y += 10 + Keys.onLeftPressed: rectangle.x += 10 + Keys.onRightPressed: rectangle.x -= 10 + } +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/userinput.qml b/src/quick/doc/snippets/qml/usecases/userinput.qml new file mode 100644 index 0000000000..887cc9ee78 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/userinput.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + id: root + + width: 320 + height: 480 + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + Rectangle { + id: rectangle + x: 40 + y: 20 + width: 120 + height: 120 + color: "red" + + MouseArea { + anchors.fill: parent + onClicked: rectangle.width += 10 + } + } +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/visual-opacity.qml b/src/quick/doc/snippets/qml/usecases/visual-opacity.qml new file mode 100644 index 0000000000..b28dbd5b2a --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/visual-opacity.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + + width: 320 + height: 480 + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + Item { + x: 20 + y: 270 + width: 200 + height: 200 + MouseArea { + anchors.fill: parent + onClicked: topRect.visible = !topRect.visible + } + Rectangle { + x: 20 + y: 20 + width: 100 + height: 100 + color: "red" + } + Rectangle { + id: topRect + opacity: 0.5 + + x: 100 + y: 100 + width: 100 + height: 100 + color: "blue" + } + } +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/visual-rects.qml b/src/quick/doc/snippets/qml/usecases/visual-rects.qml new file mode 100644 index 0000000000..f04ba13e95 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/visual-rects.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + + width: 320 + height: 480 + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + // This element displays a rectangle with a gradient and a border + Rectangle { + x: 160 + y: 20 + width: 100 + height: 100 + radius: 8 // This gives rounded corners to the Rectangle + gradient: Gradient { // This sets a vertical gradient fill + GradientStop { position: 0.0; color: "aqua" } + GradientStop { position: 1.0; color: "teal" } + } + border { width: 3; color: "white" } // This sets a 3px wide black border to be drawn + } + + // This rectangle is a plain color with no border + Rectangle { + x: 40 + y: 20 + width: 100 + height: 100 + color: "red" + } +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/visual-transforms.qml b/src/quick/doc/snippets/qml/usecases/visual-transforms.qml new file mode 100644 index 0000000000..dd22bb9500 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/visual-transforms.qml @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + + width: 320 + height: 480 + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + Rectangle { + rotation: 45 // This rotates the Rectangle by 45 degrees + x: 20 + y: 160 + width: 100 + height: 100 + color: "blue" + } + Rectangle { + scale: 0.8 // This scales the Rectangle down to 80% size + x: 160 + y: 160 + width: 100 + height: 100 + color: "green" + } +} +//![0] diff --git a/src/quick/doc/snippets/qml/usecases/visual.qml b/src/quick/doc/snippets/qml/usecases/visual.qml new file mode 100644 index 0000000000..81f3edcab3 --- /dev/null +++ b/src/quick/doc/snippets/qml/usecases/visual.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** 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$ +** +****************************************************************************/ + +//![0] +import QtQuick 2.0 + +Item { + + width: 320 + height: 480 + + Rectangle { + color: "#272822" + width: 320 + height: 480 + } + + //![image] + // This element displays an image. Because the source is online, it may take some time to fetch + Image { + x: 40 + y: 20 + width: 61 + height: 73 + source: "http://codereview.qt-project.org/static/logo_qt.png" + } + //![image] +} +//![0] |