Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. External CSS is ignored for SVGs?
Forum Updated to NodeBB v4.3 + New Features

External CSS is ignored for SVGs?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 288 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • LazyTL Offline
    LazyTL Offline
    LazyT
    wrote on last edited by
    #1

    Hello,

    I use SVGs as icons for my buttons and menus. This works fine, except the external CSS is ignored.

    The SVG contains

    <style type="text/css">
      @import url("colors.css")
    </style>
    

    and the CSS

    path { fill: red; }
    

    It is displayed in the correct color in browsers as well as in image viewers, only in my Qt Widgets App it is black.

    What's wrong, is this not supported by Qt?

    Thank you...

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      The SVG in Qt is mostly the static features of SVG 1.2 Tiny specs.
      So external CSS might not be supported at all.

      1 Reply Last reply
      0
      • LazyTL Offline
        LazyTL Offline
        LazyT
        wrote on last edited by
        #3

        Thanks for answering. So there is no chance in Qt to set the color of svgs with a single point "ressource"?

        Tried also

        <?xml-stylesheet href="colors.css" type="text/css"?>
        

        and

        setStyleSheet("path { fill: red; }");
        

        without success.

        It would be much easier to change the color dynamically instead of bundling a separate icon theme for each color.

        mrjjM 1 Reply Last reply
        0
        • LazyTL LazyT

          Thanks for answering. So there is no chance in Qt to set the color of svgs with a single point "ressource"?

          Tried also

          <?xml-stylesheet href="colors.css" type="text/css"?>
          

          and

          setStyleSheet("path { fill: red; }");
          

          without success.

          It would be much easier to change the color dynamically instead of bundling a separate icon theme for each color.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @LazyT
          Hi
          Well SVG being XML, it's possible to change it at runtime
          but how complex it is, depends on how many places / uses it has.
          You could also do it via text operations and replace all "red" with actual RGB color before using it but
          I did not find any more smart way of doing as the xml-stylesheet can.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved