在Python中的布局(或QWidget)中嵌入QQuickWidget

时间:2019-01-09 20:54:36

标签: python qml pyside2 qquickwidget

我使用Python和Pyside2,我尝试在Qwidget或Layout内插入QQuickWidget,但找不到解决方案。 我尝试使用以下代码:

.git

但是QQuickWidget在另一个窗口中启动。 我尝试使用:

.git

,但是它需要QWidget,并且不能与QQuickWidget一起使用。 我在C中发现了类似的问题,但在Python中不起作用: Adding QQuickWidget in QStackedWidget

我尝试使用QQmlApplicationEngine和QQuickView,但问题出在其中。

你能帮我吗?

编辑: main.qml文件是:

pod repo update --verbose

1 个答案:

答案 0 :(得分:1)

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
    }
}
相关问题