summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-05-13 05:07:21 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-05-13 05:07:21 (GMT)
commitae8e4afcadc9ff084e1d1859c29fbc8b629e3392 (patch)
tree675801312aa5740bc68f67444cb5754dd9e5abe1 /examples
parenta19df56265e59bb26f927638aa5c75ccd666c388 (diff)
downloadQt-ae8e4afcadc9ff084e1d1859c29fbc8b629e3392.zip
Qt-ae8e4afcadc9ff084e1d1859c29fbc8b629e3392.tar.gz
Qt-ae8e4afcadc9ff084e1d1859c29fbc8b629e3392.tar.bz2
Add an example spinner.
Also add missing increment/decrementCurrentIndex() slots to PathView, and tweak the number of points cached along a Path.
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/declarative.pro1
-rw-r--r--examples/declarative/spinner/content/Spinner.qml25
-rw-r--r--examples/declarative/spinner/content/spinner-bg.pngbin0 -> 345 bytes
-rw-r--r--examples/declarative/spinner/content/spinner-select.pngbin0 -> 320 bytes
-rw-r--r--examples/declarative/spinner/main.qml18
-rw-r--r--examples/declarative/spinner/spinner.qmlproject16
6 files changed, 60 insertions, 0 deletions
diff --git a/examples/declarative/declarative.pro b/examples/declarative/declarative.pro
index ba9b628..913b2b0 100644
--- a/examples/declarative/declarative.pro
+++ b/examples/declarative/declarative.pro
@@ -37,6 +37,7 @@ sources.files = \
scrollbar \
searchbox \
slideswitch \
+ spinner \
sql \
states \
tabwidget \
diff --git a/examples/declarative/spinner/content/Spinner.qml b/examples/declarative/spinner/content/Spinner.qml
new file mode 100644
index 0000000..8145a28
--- /dev/null
+++ b/examples/declarative/spinner/content/Spinner.qml
@@ -0,0 +1,25 @@
+import Qt 4.7
+
+Image {
+ property alias model: view.model
+ property alias delegate: view.delegate
+ property alias currentIndex: view.currentIndex
+ property real itemHeight: 30
+ source: "spinner-bg.png"
+ clip: true
+ PathView {
+ id: view
+ anchors.fill: parent
+ pathItemCount: height/itemHeight
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ highlight: Image { source: "spinner-select.png"; width: view.width; height: itemHeight+4 }
+ dragMargin: view.width/2
+ path: Path {
+ startX: view.width/2; startY: -itemHeight/2
+ PathLine { x: view.width/2; y: view.pathItemCount*itemHeight + itemHeight }
+ }
+ }
+ Keys.onDownPressed: view.incrementCurrentIndex()
+ Keys.onUpPressed: view.decrementCurrentIndex()
+}
diff --git a/examples/declarative/spinner/content/spinner-bg.png b/examples/declarative/spinner/content/spinner-bg.png
new file mode 100644
index 0000000..b3556f1
--- /dev/null
+++ b/examples/declarative/spinner/content/spinner-bg.png
Binary files differ
diff --git a/examples/declarative/spinner/content/spinner-select.png b/examples/declarative/spinner/content/spinner-select.png
new file mode 100644
index 0000000..95a17a1
--- /dev/null
+++ b/examples/declarative/spinner/content/spinner-select.png
Binary files differ
diff --git a/examples/declarative/spinner/main.qml b/examples/declarative/spinner/main.qml
new file mode 100644
index 0000000..6be567a
--- /dev/null
+++ b/examples/declarative/spinner/main.qml
@@ -0,0 +1,18 @@
+import Qt 4.7
+import "content"
+
+Rectangle {
+ width: 240; height: 320
+ Column {
+ y: 20; x: 20; spacing: 20
+ Spinner {
+ id: spinner
+ width: 200; height: 240
+ focus: true
+ model: 20
+ itemHeight: 30
+ delegate: Text { font.pixelSize: 25; text: index; height: 30 }
+ }
+ Text { text: "Current item index: " + spinner.currentIndex }
+ }
+}
diff --git a/examples/declarative/spinner/spinner.qmlproject b/examples/declarative/spinner/spinner.qmlproject
new file mode 100644
index 0000000..d4909f8
--- /dev/null
+++ b/examples/declarative/spinner/spinner.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.0
+
+Project {
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+ /* List of plugin directories passed to QML runtime */
+ // importPaths: [ " ../exampleplugin " ]
+}