diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-07-28 19:21:35 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-07-28 19:21:47 +0200 |
commit | 1a1d2e3fff5856dc9d1283b510a9f325c6fb8a93 (patch) | |
tree | 2c16537e3321cde9ca9730f871f47ed32668e120 /examples | |
parent | 4e1008b4ac1eea776585ca41a6a3db127cf500ff (diff) | |
parent | 75dd424e11964d8755abdb1b12b27a8479353b37 (diff) | |
download | qtlocation-1a1d2e3fff5856dc9d1283b510a9f325c6fb8a93.tar.gz |
Merge remote-tracking branch 'origin/5.6' into 5.7
Change-Id: I37542960aa091ab2074914a2cebb8c5114237a26
Diffstat (limited to 'examples')
-rw-r--r-- | examples/location/location.pro | 1 | ||||
-rw-r--r-- | examples/location/mapviewer/mapviewer.qml | 1 | ||||
-rw-r--r-- | examples/location/minimal_map/doc/images/minimal_map.png | bin | 0 -> 156053 bytes | |||
-rw-r--r-- | examples/location/minimal_map/doc/src/minimal_map.qdoc | 89 | ||||
-rw-r--r-- | examples/location/minimal_map/main.cpp | 53 | ||||
-rw-r--r-- | examples/location/minimal_map/main.qml | 67 | ||||
-rw-r--r-- | examples/location/minimal_map/minimal_map.pro | 10 | ||||
-rw-r--r-- | examples/location/minimal_map/qml.qrc | 6 |
8 files changed, 227 insertions, 0 deletions
diff --git a/examples/location/location.pro b/examples/location/location.pro index 851e37ac..0b4b2338 100644 --- a/examples/location/location.pro +++ b/examples/location/location.pro @@ -5,5 +5,6 @@ qtHaveModule(quick) { places_list \ places_map \ mapviewer \ + minimal_map \ planespotter } diff --git a/examples/location/mapviewer/mapviewer.qml b/examples/location/mapviewer/mapviewer.qml index 929ea4ba..08ef2663 100644 --- a/examples/location/mapviewer/mapviewer.qml +++ b/examples/location/mapviewer/mapviewer.qml @@ -82,6 +82,7 @@ ApplicationWindow { map = mapComponent.createObject(page); map.plugin = plugin; + if (zoomLevel != null) { map.zoomLevel = zoomLevel map.center = center diff --git a/examples/location/minimal_map/doc/images/minimal_map.png b/examples/location/minimal_map/doc/images/minimal_map.png Binary files differnew file mode 100644 index 00000000..31ad0f8b --- /dev/null +++ b/examples/location/minimal_map/doc/images/minimal_map.png diff --git a/examples/location/minimal_map/doc/src/minimal_map.qdoc b/examples/location/minimal_map/doc/src/minimal_map.qdoc new file mode 100644 index 00000000..06b310aa --- /dev/null +++ b/examples/location/minimal_map/doc/src/minimal_map.qdoc @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\example minimal_map +\title Minimal Map (QML) +\ingroup qtlocation-examples +\brief The minimum code to display a map using Qt Quick. + +\image minimal_map.png + +\e {Minimal Map} demonstrates how to use the \l{Map} item to render a map. +It shows the minimum amount of code needed to display the map, and can be used +as a basis for further experimentation. + +\include examples-run.qdocinc + +\section1 C++ Code + +In \c main.cpp we use only the QGuiApplication and QQmlApplicationEngine +classes. + +\quotefromfile minimal_map/main.cpp +\skipto #include +\printto main + +In the main function, we first instantiate a QGuiApplication object. +Then we create a QQmlApplicationEngine and tell it to load \c main.qml +from the \l{The Qt Resource System}{Qt Resource System}. + +Finally, QGuiApplication::exec() launches the main event loop. + +\printuntil } + +\section1 QML Code + +In \c main.qml, we import the \l {Qt Location QML Types}{QtLocation} QML module +and its depending \l {Qt Positioning QML Types}{QtPositioning} QML module. +Next, we create the top level window, set a sensible default size, and make +it visible. The window will be filled by a \l [QML]{Map} item showing the map. + +\quotefromfile minimal_map/main.qml +\skipto import +\printuntil } +\printline } +\skipto Map +\printuntil } +\printline } + +The \l [QML]{Plugin} item is necessary to define the map provider we are +going to use. The example can work with any of the available geo services +plugins. However, some plugins may require additional plugin parameters +in order to function correctly and we can use \l [QML]{PluginParameter} +to specify them. In this example, we use the \c osm plugin, which is a +\l {Qt Location Open Street Map Plugin} and does not require any parameters. + +In the \l [QML]{Map} item, we refer to the \c plugin we use and we set the \c +center and the \c zoomLevel of the map. + +\section1 Requirements + +The example requires a working internet connection to download +\c OpenStreetMap map tiles. An optional system proxy should be picked +up automatically. +*/ diff --git a/examples/location/minimal_map/main.cpp b/examples/location/minimal_map/main.cpp new file mode 100644 index 00000000..e0b58e38 --- /dev/null +++ b/examples/location/minimal_map/main.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + + return app.exec(); +} + diff --git a/examples/location/minimal_map/main.qml b/examples/location/minimal_map/main.qml new file mode 100644 index 00000000..26f24986 --- /dev/null +++ b/examples/location/minimal_map/main.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the examples of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Window 2.0 +import QtLocation 5.6 +import QtPositioning 5.6 + +Window { + width: 512 + height: 512 + visible: true + + Plugin { + id: osmPlugin + name: "osm" + // specify plugin parameters if necessary + // PluginParameter { + // name: + // value: + // } + } + + Map { + anchors.fill: parent + plugin: osmPlugin + center: QtPositioning.coordinate(59.91, 10.75) // Oslo + zoomLevel: 10 + } +} diff --git a/examples/location/minimal_map/minimal_map.pro b/examples/location/minimal_map/minimal_map.pro new file mode 100644 index 00000000..5c165252 --- /dev/null +++ b/examples/location/minimal_map/minimal_map.pro @@ -0,0 +1,10 @@ +TEMPLATE = app + +QT += location + +SOURCES += main.cpp + +RESOURCES += qml.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/location/minimal_map +INSTALLS += target diff --git a/examples/location/minimal_map/qml.qrc b/examples/location/minimal_map/qml.qrc new file mode 100644 index 00000000..0ff3892d --- /dev/null +++ b/examples/location/minimal_map/qml.qrc @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> + |