title: Can I use a gradient with a Qt Location MapPolygon?
body: <p>I have a Qt Location map upon which I'd like to draw some polygons. The <a href="http://doc.qt.io/qt-5/qml-qtlocation-mappolygon.html" rel="nofollow noreferrer"><code>MapPolygon</code></a> 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 <a href="https://doc-snapshots.qt.io/qt5-5.9/qml-qtgraphicaleffects-radialgradient.html" rel="nofollow noreferrer"><code>RadialGradient</code></a>. </p>
  
  <p>I'm playing with the <a href="http://doc.qt.io/qt-5/qtlocation-mapviewer-example.html" rel="nofollow noreferrer">Map Viewer</a> example application in Qt 5.9. I edited the <code>map/MapComponent.qml</code> QML file and added the following item to the map:</p>
  
  <pre><code>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) }
              }
          }
  }
  </code></pre>
  
  <p>The documentation for <a href="http://doc.qt.io/qt-5/qml-qtlocation-mapcircle.html" rel="nofollow noreferrer"><code>MapCircle</code></a> indicates that it uses <code>MapPolygon</code> under the hood, so I'm using it here for simplicity. If I run the test application, the gradient seems to work:</p>
  
  <p><a href="https://i.stack.imgur.com/qgqOl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qgqOl.png" alt="enter image description here"></a></p>
  
  <p>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:</p>
  
  <p><a href="https://i.stack.imgur.com/PrGUG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PrGUG.png" alt="enter image description here"></a></p>
  
  <p>Here's what appears to be happening to me:</p>
  
  <ul>
  <li><p>When the circle is clipped partially offscreen, it adjusts its bounding box to reflect the portion of the screen that it covers.</p></li>
  <li><p>Since the gradient is anchored to the parent <code>MapCircle</code> object, it automatically stretches its size to cover the clipped bounding box.</p></li>
  <li><p>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.</p></li>
  </ul>
  
  <p><strong>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.</strong></p>