Add simple example for declarative view
authorKevin Krammer <kevin.krammer@kdab.com>
Tue, 4 Dec 2012 13:04:59 +0000 (14:04 +0100)
committerKevin Krammer <kevin.krammer@kdab.com>
Tue, 4 Dec 2012 13:04:59 +0000 (14:04 +0100)
examples/declarativeview.qml [new file with mode: 0644]
examples/examples.pro

diff --git a/examples/declarativeview.qml b/examples/declarativeview.qml
new file mode 100644 (file)
index 0000000..3f0aded
--- /dev/null
@@ -0,0 +1,43 @@
+import QtGui 1.0
+
+Widget {
+  VBoxLayout {
+    HBoxLayout {
+      Label {
+        text: qsTr("Source:")
+      }
+
+      LineEdit {
+        id: sourceInput
+
+        placeholderText: qsTr("Please enter URL of a QtQuick1 QML file")
+
+        onEditingFinished: setSource()
+
+        function setSource() {
+          declarativeView.source = text
+        }
+      }
+
+      PushButton {
+        text: qsTr("Choose...");
+
+        onClicked: {
+          FileDialog.nameFilters = [ qsTr("QML files (*.qml)"), qsTr("All Files (*.*)") ]
+          var file = FileDialog.getOpenFileName();
+
+          if (file.length > 0) {
+            sourceInput.text = "file://" + file;
+            sourceInput.setSource();
+          }
+        }
+      }
+    }
+
+    DeclarativeView {
+      id: declarativeView
+
+      VBoxLayout.stretch: 1
+    }
+  }
+}
index 55dc0bc..112436c 100644 (file)
@@ -5,6 +5,7 @@ SUBDIRS += text-editor bookstore
 OTHER_FILES += \
     animation.qml \
     browser.qml \
+    declarativeview.qml \
     dialogs.qml \
     editor.qml \
     gallery.qml \