summaryrefslogtreecommitdiffstats
path: root/examples/declarative
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2010-03-02 14:00:23 (GMT)
committermae <qt-info@nokia.com>2010-03-02 14:02:53 (GMT)
commit7fd5ade07bd05ff6cb6f4e7cfa7a74081b803809 (patch)
treecec03bea7b342e4763aabf06c6a18f4bd9b95059 /examples/declarative
parent89429d192dc14044f6d27c9dde06811f1f23b954 (diff)
downloadQt-7fd5ade07bd05ff6cb6f4e7cfa7a74081b803809.zip
Qt-7fd5ade07bd05ff6cb6f4e7cfa7a74081b803809.tar.gz
Qt-7fd5ade07bd05ff6cb6f4e7cfa7a74081b803809.tar.bz2
Adapted example to use the import mechanism
Diffstat (limited to 'examples/declarative')
-rw-r--r--examples/declarative/imageprovider/ImageProviderCore/qmldir2
-rw-r--r--examples/declarative/imageprovider/imageprovider.cpp (renamed from examples/declarative/imageprovider/main.cpp)49
-rw-r--r--examples/declarative/imageprovider/imageprovider.pro14
-rw-r--r--examples/declarative/imageprovider/imageprovider.qml (renamed from examples/declarative/imageprovider/view.qml)1
-rw-r--r--examples/declarative/imageprovider/imageprovider.qrc5
5 files changed, 40 insertions, 31 deletions
diff --git a/examples/declarative/imageprovider/ImageProviderCore/qmldir b/examples/declarative/imageprovider/ImageProviderCore/qmldir
new file mode 100644
index 0000000..1028590
--- /dev/null
+++ b/examples/declarative/imageprovider/ImageProviderCore/qmldir
@@ -0,0 +1,2 @@
+plugin imageprovider
+
diff --git a/examples/declarative/imageprovider/main.cpp b/examples/declarative/imageprovider/imageprovider.cpp
index d9d4c1a..253dbf5 100644
--- a/examples/declarative/imageprovider/main.cpp
+++ b/examples/declarative/imageprovider/imageprovider.cpp
@@ -39,7 +39,8 @@
**
****************************************************************************/
-#include <QApplication>
+
+#include <qdeclarativeextensionplugin.h>
#include <qdeclarativeengine.h>
#include <qdeclarativecontext.h>
@@ -70,29 +71,37 @@ public:
}
};
-int main(int argc, char ** argv)
+
+class ImageProviderExtensionPlugin : public QDeclarativeExtensionPlugin
{
- QApplication app(argc, argv);
+ Q_OBJECT
+public:
+ void registerTypes(const char *uri) {
+ Q_UNUSED(uri);
+
+ }
- QDeclarativeView view;
+ void initializeEngine(QDeclarativeEngine *engine, const char *uri) {
+ Q_UNUSED(uri);
- view.engine()->addImageProvider("colors", new ColorImageProvider);
+ engine->addImageProvider("colors", new ColorImageProvider);
- QStringList dataList;
- dataList.append("image://colors/red");
- dataList.append("image://colors/green");
- dataList.append("image://colors/blue");
- dataList.append("image://colors/brown");
- dataList.append("image://colors/orange");
- dataList.append("image://colors/purple");
- dataList.append("image://colors/yellow");
+ QStringList dataList;
+ dataList.append("image://colors/red");
+ dataList.append("image://colors/green");
+ dataList.append("image://colors/blue");
+ dataList.append("image://colors/brown");
+ dataList.append("image://colors/orange");
+ dataList.append("image://colors/purple");
+ dataList.append("image://colors/yellow");
- QDeclarativeContext *ctxt = view.rootContext();
- ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+ QDeclarativeContext *ctxt = engine->rootContext();
+ ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
+ }
- view.setSource(QUrl("qrc:view.qml"));
- view.show();
+};
+
+#include "imageprovider.moc"
+
+Q_EXPORT_PLUGIN(ImageProviderExtensionPlugin);
- return app.exec();
-}
-//![0]
diff --git a/examples/declarative/imageprovider/imageprovider.pro b/examples/declarative/imageprovider/imageprovider.pro
index 60423ab..e403bf8 100644
--- a/examples/declarative/imageprovider/imageprovider.pro
+++ b/examples/declarative/imageprovider/imageprovider.pro
@@ -1,9 +1,11 @@
-TEMPLATE = app
-TARGET = imageprovider
-DEPENDPATH += .
-INCLUDEPATH += .
+TEMPLATE = lib
+TARGET = imageprovider
QT += declarative
+CONFIG += qt plugin
+
+TARGET = $$qtLibraryTarget($$TARGET)
+DESTDIR = ImageProviderCore
# Input
-SOURCES += main.cpp
-RESOURCES += imageprovider.qrc
+SOURCES += imageprovider.cpp
+
diff --git a/examples/declarative/imageprovider/view.qml b/examples/declarative/imageprovider/imageprovider.qml
index 2ab729d..a1f2794 100644
--- a/examples/declarative/imageprovider/view.qml
+++ b/examples/declarative/imageprovider/imageprovider.qml
@@ -1,4 +1,5 @@
import Qt 4.6
+import ImageProviderCore 1.0
//![0]
ListView {
width: 100
diff --git a/examples/declarative/imageprovider/imageprovider.qrc b/examples/declarative/imageprovider/imageprovider.qrc
deleted file mode 100644
index 17e9301..0000000
--- a/examples/declarative/imageprovider/imageprovider.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<!DOCTYPE RCC><RCC version="1.0">
-<qresource>
- <file>view.qml</file>
-</qresource>
-</RCC>