[QGIS-Developer] SVG toolbar icons suddenly appearing in black

Matthias Kuhn matthias at opengis.ch
Thu Sep 23 23:31:42 PDT 2021


Hi Raymond,

There has been an issue in Qt, where it was very picky with the <style> tag
in the svg [1]

This is solved in newer Qt versions (and newer QGIS for Windows builds) but
is still present in the early QGIS 3.16 builds based on older Qt versions.

The quick hack is to replace the <style> tag with  <style type="text/css"> in
the svg.
Or upgrade to the latest QGIS version.

Cheers
Matthias

https://bugreports.qt.io/browse/QTBUG-58326?focusedCommentId=344465&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-344465

On Fri, Sep 24, 2021 at 4:26 AM Nyall Dawson <nyall.dawson at gmail.com> wrote:

> On Thu, 23 Sept 2021 at 19:26, Raymond Nijssen <r.nijssen at terglobo.nl>
> wrote:
> >
> > Hi devs!
> >
> > The dark blue icons on my plugin toolbar buttons are black for some of
> > my customers (on Windows). One of them mentioned that they turned black
> > after a QGIS update. On my Linux system they are still blue. I guess it
> > has to do with Qt.
>
> Hi Raymond,
>
> I've seen this in the past. Seems that Qt on windows is more sensitive
> to SVG structure vs other platforms! In the past I've had luck by
> optimising the svg with https://jakearchibald.github.io/svgomg/  ,
> which seems to make Qt happier... (Turn off "Round/rewrite numbers"
> option though, cos that makes Qt LESS happy!)
>
> Nyall
>
>
> >
> >
> >
> > Here's the content of the svg file:
> >
> > <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
> >    <defs>
> >      <style>
> >        .a {
> >          fill: #1b3d6e;
> >        }
> >      </style>
> >    </defs>
> >    <path class="a"
> >
> d="M15.52,6.54a7.29,7.29,0,0,0-1.77,7.38l-9.9,9.9-.34,4.33,5.94-.6v-2.8h2.8V22h2.8l3.37-3.36a7.26,7.26,0,1,0-2.9-12Zm5.37,2.1a2,2,0,1,1,0,2.81A2,2,0,0,1,20.89,8.64Z"/>
> > </svg>
> >
> >
> >
> > And here's how I make the buttons:
> >
> > icon_fn = os.path.join(self.plugin_dir, 'img', 'icon_configuration.svg')
> > icon = QIcon(icon_fn)
> > action = QAction(icon, 'Configure', self.iface.mainWindow())
> > self.toolbar.addAction(action)
> >
> >
> >
> >
> > Hope anyone can clarify. The svg files were made by a designer, I guess
> > in some Adobe application. Hope I don't need adjusting them.
> >
> > Kind regards,
> > Raymond
> >
> > _______________________________________________
> > QGIS-Developer mailing list
> > QGIS-Developer at lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210924/de6be57a/attachment.html>


More information about the QGIS-Developer mailing list