user17312099
user17312099

Reputation: 21

how can i add QtLocation plugin in pyside project to use Map in qml? - SOLVED

i created an app in qt creator that displays a simple map and i want to do the same in pyside project without using webengine. this is my code in qml:

import QtQuick 2.0
import QtPositioning 5.5
import QtLocation 5.6
import QtQuick.Controls 2.0

Item
{
id: root
visible: true

Plugin
{
    id: osmPlug
    name: "osm"
    
    PluginParameter
    {
        name: "osm.mapping.providersrepository.disabled"
        value: "true"
    }
    PluginParameter
    {
        name: "osm.mapping.providersrepository.address"
        value: "http://maps-redirect.qt.io/osm/5.6/"
    }
}

Map
{
    id: map
    anchors.fill: parent
    plugin: osmPlug
    center: QtPositioning.coordinate(59.91, 10.75) // Oslo
    zoomLevel: 3
    copyrightsVisible: false
    fieldOfView: 15
}
}

this code in a pyside project ( in qtcreator ) returns this error: module "QtLocation" is not installed

python code:

# This Python file uses the following encoding: utf-8
import sys
from pathlib import Path

from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine


if __name__ == "__main__":
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
qml_file = Path(__file__).resolve().parent / "main.qml"
engine.load(qml_file)
if not engine.rootObjects():
    sys.exit(-1)
sys.exit(app.exec())

how can i solve this problem?

Thanks in advance

EDIT:

''' answer in comments '''

Upvotes: 2

Views: 913

Answers (0)

Related Questions