diff options
Diffstat (limited to 'examples')
19 files changed, 117 insertions, 95 deletions
diff --git a/examples/declarative/animation/color-animation.qml b/examples/declarative/animation/color-animation.qml index 0cf8a44..edb0659 100644 --- a/examples/declarative/animation/color-animation.qml +++ b/examples/declarative/animation/color-animation.qml @@ -30,18 +30,18 @@ Item { // the sun, moon, and stars Item { width: parent.width; height: 2 * parent.height - transformOrigin: "Center" + transformOrigin: Item.Center rotation: SequentialAnimation { running: true; repeat: true NumberAnimation { from: 0; to: 360; duration: 10000 } } Image { source: "images/sun.png"; y: 10; anchors.horizontalCenter: parent.horizontalCenter - transformOrigin: "Center"; rotation: -3 * parent.rotation + transformOrigin: Item.Center; rotation: -3 * parent.rotation } Image { source: "images/moon.png"; y: parent.height - 74; anchors.horizontalCenter: parent.horizontalCenter - transformOrigin: "Center"; rotation: -parent.rotation + transformOrigin: Item.Center; rotation: -parent.rotation } Particles { x: 0; y: parent.height/2; width: parent.width; height: parent.height/2 diff --git a/examples/declarative/animation/easing.qml b/examples/declarative/animation/easing.qml index 9e0a0d6..59e9b17 100644 --- a/examples/declarative/animation/easing.qml +++ b/examples/declarative/animation/easing.qml @@ -92,7 +92,7 @@ Rectangle { anchors.fill: parent; viewportHeight: layout.height Column { id: layout - anchors.left: window.left; anchors.right: window.right + anchors.left: parent.left; anchors.right: parent.right Repeater { model: easingTypes; delegate: delegate } } } diff --git a/examples/declarative/animation/property-animation.qml b/examples/declarative/animation/property-animation.qml index 4e0f6f4..0256137 100644 --- a/examples/declarative/animation/property-animation.qml +++ b/examples/declarative/animation/property-animation.qml @@ -26,7 +26,7 @@ Item { Image { anchors.horizontalCenter: parent.horizontalCenter source: "images/shadow.png"; y: smiley.minHeight + 58 - transformOrigin: "Center" + transformOrigin: Item.Center // The scale property depends on the y position of the smiley face. scale: smiley.y * 0.5 / (smiley.minHeight - smiley.maxHeight) diff --git a/examples/declarative/connections/Button.qml b/examples/declarative/connections/Button.qml new file mode 100644 index 0000000..1d46acc --- /dev/null +++ b/examples/declarative/connections/Button.qml @@ -0,0 +1,12 @@ +import Qt 4.6 + +Item { + id: button + width: 48; height: 48 + + property alias image: icon.source + signal clicked + + Image { id: icon } + MouseRegion { anchors.fill: icon; onClicked: button.clicked() } +} diff --git a/examples/declarative/connections/bg1.jpg b/examples/declarative/connections/bg1.jpg Binary files differnew file mode 100644 index 0000000..dfc7cee --- /dev/null +++ b/examples/declarative/connections/bg1.jpg diff --git a/examples/declarative/connections/connections.qml b/examples/declarative/connections/connections.qml index b693b7e..5dc211e 100644 --- a/examples/declarative/connections/connections.qml +++ b/examples/declarative/connections/connections.qml @@ -1,32 +1,30 @@ import Qt 4.6 Rectangle { - id: rect - color: "blue" - width: 40 - height: 30 + id: window; color: "#343434" + width: 640; height: 480 - Rectangle { - id: dot - color: "red" - width: 3 - height: 3 - x: rect.width/2 - y: rect.height/2 + function turnLeft() { + image.rotation -= 90 + } + function turnRight() { + image.rotation += 90 } - MouseRegion { - id: mr - anchors.fill: rect + Image { + id: image; source: "bg1.jpg"; anchors.centerIn: parent; transformOrigin: Item.Center + rotation: Behavior { NumberAnimation { easing: "easeOutCubic"; duration: 300 } } } - Connection { - sender: mr - signal: "clicked(mouse)" - script: { - color = "green"; - dot.x = mouse.x-1; - dot.y = mouse.y-1; - } + Button { + id: leftButton; image: "rotate-left.png" + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 10 } + } + Button { + id: rightButton; image: "rotate-right.png" + anchors { right: parent.right; bottom: parent.bottom; rightMargin: 10; bottomMargin: 10 } } + + Connection { sender: leftButton; signal: "clicked()"; script: window.turnLeft() } + Connection { sender: rightButton; signal: "clicked()"; script: window.turnRight() } } diff --git a/examples/declarative/connections/rotate-left.png b/examples/declarative/connections/rotate-left.png Binary files differnew file mode 100644 index 0000000..c30387e --- /dev/null +++ b/examples/declarative/connections/rotate-left.png diff --git a/examples/declarative/connections/rotate-right.png b/examples/declarative/connections/rotate-right.png Binary files differnew file mode 100644 index 0000000..1b05674 --- /dev/null +++ b/examples/declarative/connections/rotate-right.png diff --git a/examples/declarative/extending/attached/birthdayparty.h b/examples/declarative/extending/attached/birthdayparty.h index 8249af5..2ea065c 100644 --- a/examples/declarative/extending/attached/birthdayparty.h +++ b/examples/declarative/extending/attached/birthdayparty.h @@ -9,7 +9,7 @@ class BirthdayPartyAttached : public QObject { Q_OBJECT -Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp); +Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) public: BirthdayPartyAttached(QObject *object); @@ -19,7 +19,7 @@ public: private: QDate m_rsvp; }; -QML_DECLARE_TYPE(BirthdayPartyAttached); +QML_DECLARE_TYPE(BirthdayPartyAttached) class BirthdayParty : public QObject { @@ -40,6 +40,8 @@ private: Person *m_celebrant; QmlConcreteList<Person *> m_guests; }; -QML_DECLARE_TYPE(BirthdayParty); + +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(BirthdayParty) #endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/binding/birthdayparty.h b/examples/declarative/extending/binding/birthdayparty.h index 6905746..2757561 100644 --- a/examples/declarative/extending/binding/birthdayparty.h +++ b/examples/declarative/extending/binding/birthdayparty.h @@ -10,7 +10,7 @@ class BirthdayPartyAttached : public QObject { Q_OBJECT -Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged); +Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp NOTIFY rsvpChanged) public: BirthdayPartyAttached(QObject *object); @@ -23,7 +23,7 @@ signals: private: QDate m_rsvp; }; -QML_DECLARE_TYPE(BirthdayPartyAttached); +QML_DECLARE_TYPE(BirthdayPartyAttached) class BirthdayParty : public QObject { @@ -56,6 +56,8 @@ private: Person *m_celebrant; QmlConcreteList<Person *> m_guests; }; -QML_DECLARE_TYPE(BirthdayParty); + +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(BirthdayParty) #endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/signal/birthdayparty.h b/examples/declarative/extending/signal/birthdayparty.h index 14d7c29..5dea2e8 100644 --- a/examples/declarative/extending/signal/birthdayparty.h +++ b/examples/declarative/extending/signal/birthdayparty.h @@ -9,7 +9,7 @@ class BirthdayPartyAttached : public QObject { Q_OBJECT -Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp); +Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) public: BirthdayPartyAttached(QObject *object); @@ -19,7 +19,7 @@ public: private: QDate m_rsvp; }; -QML_DECLARE_TYPE(BirthdayPartyAttached); +QML_DECLARE_TYPE(BirthdayPartyAttached) class BirthdayParty : public QObject { @@ -47,6 +47,8 @@ private: Person *m_celebrant; QmlConcreteList<Person *> m_guests; }; -QML_DECLARE_TYPE(BirthdayParty); + +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(BirthdayParty) #endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/extending/valuesource/birthdayparty.h b/examples/declarative/extending/valuesource/birthdayparty.h index fd25f28..75a2477 100644 --- a/examples/declarative/extending/valuesource/birthdayparty.h +++ b/examples/declarative/extending/valuesource/birthdayparty.h @@ -10,7 +10,7 @@ class BirthdayPartyAttached : public QObject { Q_OBJECT -Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp); +Q_PROPERTY(QDate rsvp READ rsvp WRITE setRsvp) public: BirthdayPartyAttached(QObject *object); @@ -20,7 +20,7 @@ public: private: QDate m_rsvp; }; -QML_DECLARE_TYPE(BirthdayPartyAttached); +QML_DECLARE_TYPE(BirthdayPartyAttached) class BirthdayParty : public QObject { @@ -52,6 +52,8 @@ private: Person *m_celebrant; QmlConcreteList<Person *> m_guests; }; -QML_DECLARE_TYPE(BirthdayParty); + +QML_DECLARE_TYPEINFO(BirthdayParty, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(BirthdayParty) #endif // BIRTHDAYPARTY_H diff --git a/examples/declarative/progressbar/ProgressBar.qml b/examples/declarative/progressbar/ProgressBar.qml index 48346ac..302caa9 100644 --- a/examples/declarative/progressbar/ProgressBar.qml +++ b/examples/declarative/progressbar/ProgressBar.qml @@ -21,7 +21,7 @@ Item { id: highlight; radius: 2 anchors.left: parent.left; anchors.top: parent.top; anchors.bottom: parent.bottom anchors.leftMargin: 3; anchors.topMargin: 3; anchors.bottomMargin: 3 - width: EaseFollow { source: highlight.widthDest; duration: 100 } + width: EaseFollow { source: highlight.widthDest; duration: 1000 } gradient: Gradient { GradientStop { id: g1; position: 0.0 } GradientStop { id: g2; position: 1.0 } diff --git a/examples/declarative/snow/ImageBatch.qml b/examples/declarative/snow/ImageBatch.qml index 3945087..dfe2a46 100644 --- a/examples/declarative/snow/ImageBatch.qml +++ b/examples/declarative/snow/ImageBatch.qml @@ -38,7 +38,7 @@ GridView { delegate: Item { id: root property bool isSelected: GridView.isCurrentItem && grid.isSelected - transformOrigin: "Center" + transformOrigin: Item.Center width: grid.imageWidth; height: grid.imageHeight; Image { id: flickrImage; source: url; fillMode: "PreserveAspectFit"; smooth: true; anchors.fill: parent; diff --git a/examples/declarative/snow/Loading.qml b/examples/declarative/snow/Loading.qml index 054656a..238d9c7 100644 --- a/examples/declarative/snow/Loading.qml +++ b/examples/declarative/snow/Loading.qml @@ -1,7 +1,7 @@ import Qt 4.6 Image { - id: loading; source: "pics/loading.png"; transformOrigin: "Center" + id: loading; source: "pics/loading.png"; transformOrigin: Item.Center rotation: NumberAnimation { id: rotationAnimation; from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 } diff --git a/examples/declarative/states/states.qml b/examples/declarative/states/states.qml index acab2f0..6f6b40f 100644 --- a/examples/declarative/states/states.qml +++ b/examples/declarative/states/states.qml @@ -2,47 +2,49 @@ import Qt 4.6 Rectangle { id: page - width: 300; height: 300; color: "white" - // A target region. Clicking in here sets the state to '' - the default state + width: 640; height: 480; color: "#343434" + + // A target region. Clicking in here sets the state to the default state Rectangle { - x: 0; y: 0; width: 50; height: 50 - color: "transparent"; border.color: "black" - MouseRegion { anchors.fill: parent; onClicked: { page.state='' } } + id: initialPosition + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 64; height: 64; radius: 6 + color: "Transparent"; border.color: "Gray" + MouseRegion { anchors.fill: parent; onClicked: page.state = '' } } + // Another target region. Clicking in here sets the state to 'Position1' Rectangle { - x: 150; y: 50; width: 50; height: 50 - color: "transparent"; border.color: "black" - MouseRegion { anchors.fill: parent; onClicked: { page.state='Position1' } } + id: position1 + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 64; height: 64; radius: 6 + color: "Transparent"; border.color: "Gray" + MouseRegion { anchors.fill: parent; onClicked: page.state = 'Position1' } } + // Another target region. Clicking in here sets the state to 'Position2' Rectangle { - x: 0; y: 200; width: 50; height: 50 - color: "transparent"; border.color: "black" - MouseRegion { anchors.fill: parent; onClicked: { page.state='Position2' } } + id: position2 + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 64; height: 64; radius: 6 + color: "Transparent"; border.color: "Gray" + MouseRegion { anchors.fill: parent; onClicked: page.state = 'Position2' } } - // Rect which will be moved when my state changes - Rectangle { id: myrect; width: 50; height: 50; color: "red" } + + // The image which will be moved when my state changes + Image { id: user; source: "user.png"; x: initialPosition.x; y: initialPosition.y } states: [ - // In state 'Position1', change the 'myrect' item x, y to 150, 50. + // In state 'Position1', change the 'user' item position to rect2's position. State { name: "Position1" - PropertyChanges { - target: myrect - x: 150 - y: 50 - } + PropertyChanges { target: user; x: position1.x; y: position1.y } }, - // In state 'Position2', change y to 100. We do not specify 'x' here - - // it will therefore be restored to its default value of 0, if it - // had been changed. + + // In state 'Position2', change the 'user' item position to rect3's position. State { name: "Position2" - PropertyChanges { - target: myrect - y: 200 - } + PropertyChanges { target: user; x: position2.x; y: position2.y } } ] } diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml index cc6894d..ba97d9be 100644 --- a/examples/declarative/states/transitions.qml +++ b/examples/declarative/states/transitions.qml @@ -2,47 +2,49 @@ import Qt 4.6 Rectangle { id: page - width: 300; height: 300; color: "white" - // A target region. Clicking in here sets the state to '' - the default state + width: 640; height: 480; color: "#343434" + + // A target region. Clicking in here sets the state to the default state Rectangle { - x: 0; y: 0; width: 50; height: 50 - color: "transparent"; border.color: "black" - MouseRegion { anchors.fill: parent; onClicked: { page.state='' } } + id: initialPosition + anchors { left: parent.left; top: parent.top; leftMargin: 10; topMargin: 20 } + width: 64; height: 64; radius: 6 + color: "Transparent"; border.color: "Gray" + MouseRegion { anchors.fill: parent; onClicked: page.state = '' } } + // Another target region. Clicking in here sets the state to 'Position1' Rectangle { - x: 150; y: 50; width: 50; height: 50 - color: "transparent"; border.color: "black" - MouseRegion { anchors.fill: parent; onClicked: { page.state='Position1' } } + id: position1 + anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: 20 } + width: 64; height: 64; radius: 6 + color: "Transparent"; border.color: "Gray" + MouseRegion { anchors.fill: parent; onClicked: page.state = 'Position1' } } + // Another target region. Clicking in here sets the state to 'Position2' Rectangle { - x: 0; y: 200; width: 50; height: 50 - color: "transparent"; border.color: "black" - MouseRegion { anchors.fill: parent; onClicked: { page.state='Position2' } } + id: position2 + anchors { left: parent.left; bottom: parent.bottom; leftMargin: 10; bottomMargin: 20 } + width: 64; height: 64; radius: 6 + color: "Transparent"; border.color: "Gray" + MouseRegion { anchors.fill: parent; onClicked: page.state = 'Position2' } } - // Rect which will be moved when my state changes - Rectangle { id: myrect; width: 50; height: 50; color: "red" } + + // The image which will be moved when my state changes + Image { id: user; source: "user.png"; x: initialPosition.x; y: initialPosition.y } states: [ - // In state 'Position1', change the 'myrect' item x, y to 150, 50. + // In state 'Position1', change the 'user' item position to rect2's position. State { name: "Position1" - PropertyChanges { - target: myrect - x: 150 - y: 50 - } + PropertyChanges { target: user; x: position1.x; y: position1.y } }, - // In state 'Position2', change y to 100. We do not specify 'x' here - - // it will therefore be restored to its default value of 0, if it - // had been changed. + + // In state 'Position2', change the 'user' item position to rect3's position. State { name: "Position2" - PropertyChanges { - target: myrect - y: 200 - } + PropertyChanges { target: user; x: position2.x; y: position2.y } } ] diff --git a/examples/declarative/states/user.png b/examples/declarative/states/user.png Binary files differnew file mode 100644 index 0000000..dd7d7a2 --- /dev/null +++ b/examples/declarative/states/user.png diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml index d641eba..534d663 100644 --- a/examples/declarative/tutorials/helloworld/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/tutorial3.qml @@ -11,7 +11,7 @@ Rectangle { text: "Hello world!" font.pointSize: 24; font.bold: true y: 30; anchors.horizontalCenter: page.horizontalCenter - transformOrigin: "Center" + transformOrigin: Item.Center //![1] MouseRegion { id: mouseRegion; anchors.fill: parent } |