summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLorn Potter <lorn.potter@nokia.com>2010-07-14 22:37:26 (GMT)
committerLorn Potter <lorn.potter@nokia.com>2010-07-14 22:37:26 (GMT)
commitf238f6b05d444dc71022e91f40e0ade6094c5800 (patch)
treebdde436b157db6a3dd4c424c619f9a4306db96f4 /examples
parent423e373ed0935ebe3d2f54a4c56101081c3311b5 (diff)
parent6536b6f16ff26579f191543e5d468a6382211a29 (diff)
downloadQt-f238f6b05d444dc71022e91f40e0ade6094c5800.zip
Qt-f238f6b05d444dc71022e91f40e0ade6094c5800.tar.gz
Qt-f238f6b05d444dc71022e91f40e0ade6094c5800.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/cppextensions/imageprovider/imageprovider.cpp2
-rw-r--r--examples/declarative/touchinteraction/mousearea/mousearea-example.qml64
2 files changed, 38 insertions, 28 deletions
diff --git a/examples/declarative/cppextensions/imageprovider/imageprovider.cpp b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp
index 995192a..18d027e 100644
--- a/examples/declarative/cppextensions/imageprovider/imageprovider.cpp
+++ b/examples/declarative/cppextensions/imageprovider/imageprovider.cpp
@@ -54,7 +54,7 @@ class ColorImageProvider : public QDeclarativeImageProvider
{
public:
ColorImageProvider()
- : QDeclarativeImageProvider(Pixmap)
+ : QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap)
{
}
diff --git a/examples/declarative/touchinteraction/mousearea/mousearea-example.qml b/examples/declarative/touchinteraction/mousearea/mousearea-example.qml
index 64f72a9..85ea2dc 100644
--- a/examples/declarative/touchinteraction/mousearea/mousearea-example.qml
+++ b/examples/declarative/touchinteraction/mousearea/mousearea-example.qml
@@ -44,59 +44,69 @@ Rectangle {
id: box
width: 350; height: 250
- function showInfo(text) {
- statusText.text = text
- }
-
Rectangle {
+ id: redSquare
width: 80; height: 80
+ anchors.top: parent.top; anchors.left: parent.left; anchors.margins: 10
color: "red"
Text { text: "Click"; font.pixelSize: 16; anchors.centerIn: parent }
MouseArea {
- anchors.fill: parent
+ anchors.fill: parent
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
- onPressed: box.showInfo('Pressed (x=' + mouse.x + ' y=' + mouse.y + ' button='
- + (mouse.button == Qt.RightButton ? 'right' : 'left')
- + ' Shift=' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')')
- onReleased: box.showInfo('Released (x=' + mouse.x + ' y=' + mouse.y
- + ' isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')')
- onClicked: box.showInfo('Clicked (x=' + mouse.x + ' y=' + mouse.y + ' wasHeld=' + mouse.wasHeld + ')')
- onDoubleClicked: box.showInfo('Double clicked (x=' + mouse.x + ' y=' + mouse.y + ')')
- onPressAndHold: box.showInfo('Press and hold')
- onEntered: box.showInfo('Entered (pressed=' + pressed + ')')
- onExited: box.showInfo('Exited (pressed=' + pressed + ')')
+ onEntered: info.text = 'Entered'
+ onExited: info.text = 'Exited (pressed=' + pressed + ')'
+
+ onPressed: {
+ info.text = 'Pressed (button=' + (mouse.button == Qt.RightButton ? 'right' : 'left')
+ + ' shift=' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')'
+ var posInBox = redSquare.mapToItem(box, mouse.x, mouse.y)
+ posInfo.text = + mouse.x + ',' + mouse.y + ' in square'
+ + ' (' + posInBox.x + ',' + posInBox.y + ' in window)'
+ }
+
+ onReleased: {
+ info.text = 'Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')'
+ posInfo.text = ''
+ }
+
+ onPressAndHold: info.text = 'Press and hold'
+ onClicked: info.text = 'Clicked (wasHeld=' + mouse.wasHeld + ')'
+ onDoubleClicked: info.text = 'Double clicked'
}
}
Rectangle {
- width: 80; height: 80; anchors.right: parent.right
+ id: blueSquare
+ width: 80; height: 80
+ x: box.width - width - 10; y: 10 // making this item draggable, so don't use anchors
color: "blue"
Text { text: "Drag"; font.pixelSize: 16; color: "white"; anchors.centerIn: parent }
MouseArea {
anchors.fill: parent
- drag.target: parent
- drag.axis: Drag.XAxis
+ drag.target: blueSquare
+ drag.axis: Drag.XandYAxis
drag.minimumX: 0
- drag.maximumX: 150
-
- onPressed: box.showInfo('Pressed')
- onReleased: box.showInfo('Released (isClick=' + mouse.isClick + ' wasHeld=' + mouse.wasHeld + ')')
- onClicked: box.showInfo('Clicked' + ' (wasHeld=' + mouse.wasHeld + ')')
- onDoubleClicked: box.showInfo('Double clicked')
- onPressAndHold: box.showInfo('Press and hold')
+ drag.maximumX: box.width - parent.width
+ drag.minimumY: 0
+ drag.maximumY: box.height - parent.width
}
}
Text {
- id: statusText
- anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30
+ id: info
+ anchors.bottom: posInfo.top; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30
onTextChanged: console.log(text)
}
+
+ Text {
+ id: posInfo
+ anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; anchors.margins: 30
+ }
}