qt-quick-for-designers-1:components
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
qt-quick-for-designers-1:components [2013/06/22 03:20] – created mithat | qt-quick-for-designers-1:components [2013/07/06 22:53] (current) – [Resources] mithat | ||
---|---|---|---|
Line 46: | Line 46: | ||
</ | </ | ||
* '' | * '' | ||
+ | |||
+ | ===== Properties ===== | ||
+ | * You can declare a '' | ||
+ | <file javascript ButtonSimple2.qml> | ||
+ | import QtQuick 1.0 | ||
+ | |||
+ | Image { | ||
+ | id: button | ||
+ | source: " | ||
+ | |||
+ | property string labelText | ||
+ | |||
+ | Text { | ||
+ | id: label | ||
+ | text: labelText | ||
+ | color: " | ||
+ | anchors.horizontalCenter: | ||
+ | anchors.top: | ||
+ | anchors.topMargin: | ||
+ | } | ||
+ | |||
+ | MouseArea { | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | }</ | ||
+ | |||
+ | <file javascript reusing-buttonsimple2.qml> | ||
+ | import QtQuick 1.0 | ||
+ | |||
+ | Item { | ||
+ | id: myItem | ||
+ | width: 400 | ||
+ | height: 400 | ||
+ | |||
+ | ButtonSimple2 { | ||
+ | id: myButton | ||
+ | labelText: "Hey you!" | ||
+ | anchors.horizontalCenter: | ||
+ | anchors.bottom: | ||
+ | anchors.bottomMargin: | ||
+ | } | ||
+ | }</ | ||
+ | |||
+ | ===== 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 '' | ||
+ | <file javascript resuing-button.qml> | ||
+ | import QtQuick 1.0 | ||
+ | |||
+ | Item { | ||
+ | id: myItem | ||
+ | width: 400 | ||
+ | height: 400 | ||
+ | |||
+ | Button { | ||
+ | id: button | ||
+ | labelText: " | ||
+ | anchors.horizontalCenter: | ||
+ | anchors.bottom: | ||
+ | anchors.bottomMargin: | ||
+ | |||
+ | onButtonClicked: | ||
+ | button.labelText=" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | -------------------------------------------------------------- | ||
+ | ====== Resources ====== | ||
+ | * {{: | ||
+ | * All source code is subject to this [[copyright header|copyright]]. |
qt-quick-for-designers-1/components.1371871234.txt.gz · Last modified: 2013/06/22 03:20 by mithat