I use Python and Pyside2, I try to insert a QQuickWidget inside a Qwidget or inside a Layout but I haven't find a solution. I try with this code:
view = QQuickWidget()
view.setSource(QUrl.fromLocalFile("main.qml"))
but QQuickWidget start in another windows. I try use:
Layout.addWidget(view)
but it required a QWidget and don't work with QQuickWidget. I found this similar question (in C) but it don't work in Python: Adding QQuickWidget in QStackedWidget
I have try QQmlApplicationEngine and QQuickView, but problem is the some.
Can you help me ?
Edit: main.qml file is:
import QtQuick 2.0
import QtQuick.Window 2.0
import QtLocation 5.6
import QtPositioning 5.6
Window {
width: 300
height: 300
visible: true
Plugin {
id: mapPlugin
name: "esri"
}
Map {
anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(39.2160, 9.1344)
zoomLevel: 16
}
}
The problem is that the root element is a Window that will create a window, the solution is to use an Item:
import QtQuick 2.0
import QtLocation 5.6
import QtPositioning 5.6
Item {
width: 300
height: 300
Plugin {
id: mapPlugin
name: "esri"
}
Map {
anchors.fill: parent
plugin: mapPlugin
center: QtPositioning.coordinate(39.2160, 9.1344)
zoomLevel: 16
}
}