From 33cb6eda2337c7f92d68d5b9f60c652c842788fe Mon Sep 17 00:00:00 2001 From: Kevin Krammer Date: Tue, 4 Dec 2012 14:04:59 +0100 Subject: [PATCH] Add simple example for declarative view --- examples/declarativeview.qml | 43 ++++++++++++++++++++++++++++++++++++++++++ examples/examples.pro | 1 + 2 files changed, 44 insertions(+), 0 deletions(-) create mode 100644 examples/declarativeview.qml diff --git a/examples/declarativeview.qml b/examples/declarativeview.qml new file mode 100644 index 0000000..3f0aded --- /dev/null +++ b/examples/declarativeview.qml @@ -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 + } + } +} diff --git a/examples/examples.pro b/examples/examples.pro index 55dc0bc..112436c 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -5,6 +5,7 @@ SUBDIRS += text-editor bookstore OTHER_FILES += \ animation.qml \ browser.qml \ + declarativeview.qml \ dialogs.qml \ editor.qml \ gallery.qml \ -- 1.7.2.5