qt-quick-for-designers-1:components
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
qt-quick-for-designers-1:components [2013/06/22 04:16] – mithat | qt-quick-for-designers-1:components [2013/06/22 04:24] – [Signals] mithat | ||
---|---|---|---|
Line 93: | Line 93: | ||
===== Signals ===== | ===== Signals ===== | ||
+ | * A '' | ||
+ | * In the Button below, '' | ||
+ | <file javascript Button.qml> | ||
+ | import QtQuick 1.0 | ||
+ | |||
+ | Image { | ||
+ | id: button | ||
+ | source: " | ||
+ | |||
+ | property string labelText | ||
+ | signal buttonClicked() | ||
+ | |||
+ | Text { | ||
+ | id: label | ||
+ | text: labelText | ||
+ | color: " | ||
+ | anchors.horizontalCenter: | ||
+ | anchors.top: | ||
+ | anchors.topMargin: | ||
+ | } | ||
+ | |||
+ | MouseArea { | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | }</ | ||
+ | * The actual behavior is defined in the file where Button is used (as the Button' | ||
+ | <file javascript resuing-button.qml> | ||
+ | import QtQuick 1.0 | ||
+ | |||
+ | import " | ||
+ | |||
+ | Item { | ||
+ | id: myItem | ||
+ | width: 400 | ||
+ | height: 400 | ||
+ | |||
+ | property int actualStateNumber: | ||
+ | |||
+ | Image { | ||
+ | source: " | ||
+ | } | ||
+ | |||
+ | Image { | ||
+ | id: spaceship | ||
+ | x: -200 | ||
+ | y: 50 | ||
+ | source: " | ||
+ | } | ||
+ | |||
+ | Button { | ||
+ | id: button | ||
+ | labelText: " | ||
+ | anchors.horizontalCenter: | ||
+ | anchors.bottom: | ||
+ | anchors.bottomMargin: | ||
+ | |||
+ | onButtonClicked: | ||
+ | myItem.state = RandomFunction.randomState(); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | | ||
+ | State { | ||
+ | name: " | ||
+ | | ||
+ | | ||
+ | x: 250 | ||
+ | y: 200 | ||
+ | } | ||
+ | }, | ||
+ | State { | ||
+ | name: " | ||
+ | | ||
+ | | ||
+ | x: 100 | ||
+ | y: 200 | ||
+ | } | ||
+ | }, | ||
+ | State { | ||
+ | name: " | ||
+ | | ||
+ | | ||
+ | x: 10 | ||
+ | y: 50 | ||
+ | } | ||
+ | }, | ||
+ | State { | ||
+ | name: " | ||
+ | | ||
+ | | ||
+ | x: 100 | ||
+ | y: 50 | ||
+ | } | ||
+ | } | ||
+ | ] | ||
+ | |||
+ | transitions: | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | }, | ||
+ | | ||
+ | from: "" | ||
+ | to: " | ||
+ | | ||
+ | PauseAnimation { | ||
+ | | ||
+ | } | ||
+ | |||
+ | NumberAnimation { | ||
+ | properties: " | ||
+ | duration: 500 | ||
+ | easing.type: | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | ] | ||
+ | |||
+ | Component.onCompleted: | ||
+ | myItem.state = " | ||
+ | } | ||
+ | |||
+ | } | ||
+ | </ | ||
qt-quick-for-designers-1/components.txt · Last modified: 2013/07/06 22:53 by mithat