I have a Qt Location map upon which I'd like to draw some polygons. The MapPolygon
class provides an easy way to drape a polygon over the terrain, as desired. I would like to shade the polygon using a gradient, like RadialGradient
.
I'm playing with the Map Viewer example application in Qt 5.9. I edited the map/MapComponent.qml
QML file and added the following item to the map:
MapCircle {
center {
latitude: -27.5
longitude: 153.0
}
radius: 5000.0
border.width: 0
RadialGradient {
anchors.fill: parent
gradient: Gradient {
GradientStop { position: 0.0; color: "red" }
GradientStop { position: 0.25; color: "red" }
GradientStop { position: 0.5; color: Qt.rgba(0, 0, 0, 0) }
}
}
}
The documentation for MapCircle
indicates that it uses MapPolygon
under the hood, so I'm using it here for simplicity. If I run the test application, the gradient seems to work:
This is what I would like. However, if I scroll the viewport so that part of the circle is clipped out of the viewable area, the gradient doesn't look right:
Here's what appears to be happening to me:
When the circle is clipped partially offscreen, it adjusts its bounding box to reflect the portion of the screen that it covers.
Since the gradient is anchored to the parent
MapCircle
object, it automatically stretches its size to cover the clipped bounding box.This results in the entire radial gradient shape being rendered in the compressed bounding box, which is not what I want. I want the gradient object's geometry to stay attached to the circle's true size and location. Instead of the compressed gradient that I see in the second picture, I want to see a similarly-clipped portion of the original radial gradient.
Is this possible with Qt 5.9? It's not clear to me whether this is a rendering bug, or if it's just not intended to be usable this way.