Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt MapPolygon QML图像背景_Qt_Qml - Fatal编程技术网

Qt MapPolygon QML图像背景

Qt MapPolygon QML图像背景,qt,qml,Qt,Qml,我可以在地图上画一个多边形,这个多边形是一个矩形,我可以旋转它或重新缩放它。 问题是,我想在这个矩形中绘制一个qpixmap作为背景,但我不知道怎么做,可能吗?MapPolygon中没有任何属性可以指定qpixmap到其中 Map { id: mapBase gesture.enabled: true anchors.fill: parent plugin: mapPlugin center: QtPositioning.coordinate(45,10)

我可以在地图上画一个多边形,这个多边形是一个矩形,我可以旋转它或重新缩放它。 问题是,我想在这个矩形中绘制一个qpixmap作为背景,但我不知道怎么做,可能吗?MapPolygon中没有任何属性可以指定qpixmap到其中

Map {
    id: mapBase
    gesture.enabled: true
    anchors.fill: parent
    plugin: mapPlugin
    center: QtPositioning.coordinate(45,10)
    zoomLevel: 4
    z: parent.z + 1
    MapPolygon {
        color: 'green'
        path: [
            { latitude: -27, longitude: 153.0 },
            { latitude: -27, longitude: 154.1 },
            { latitude: -28, longitude: 153.5 }
        ]
    }
}
您可以使用,并结合使用QML映像

    MapPolygon {
        id: polygon
        color: 'white' // Any color, only alpha channel will be used
        path: [
            { latitude: -27, longitude: 153.0 },
            { latitude: -27, longitude: 154.1 },
            { latitude: -28, longitude: 153.5 }
        ]
        visible: false
    }

    Image {
        id: image
        source: "myImage.png"
        visible: false // hide it so it does not appear over the masked image
    }

    OpacityMask  // Actual masked image
    {
        source: image
        maskSource: polygon
        anchors.fill: polygon
    }

显示您的代码。@eyllanesc谢谢我已经更新了我的帖子。非常感谢,如果我画一个矩形,我能把图像放进去吗?可能吗?