Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-14001

Incorrect CSS handling in Qt Svg module

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P3: Somewhat important
    • None
    • 4.7.0
    • SVG Support
    • None
    • Win XP SP3

    Description

      I have a SVG which uses a CSS file. I find if some SVG style attributes are split between CSS and SVG, the QSvgRenderer does not handle it correctly.

      Take this SVG element
      <rect width="50" height="30" fill-opacity="0.5" class="myfill">

      and the CSS that defines the fill attribute is
      .myfill

      { fill: #ff0000; }

      So, I should get a 0.5 opacity red rectangle in my SVG. This works fine in various browsers like Chrome and Firefox, but when I use Qt SVG module to render this, it does not work properly.

      I ran through the code and find that the switch case for handling CSS elements searches for the starting letter of the element and the whole logic is based on that. So when fill and fill-opacity are split between the SVG and CSS, this does not work. But if I have both fill and fill-opacity in the same place (either both in the SVG or both in the CSS), then the Qt SVG renderer shows the rectangle correctly! I think this approach of parsing the CSS is not the best way to do it.

      Attachments

        1. failed1.svg
          1 kB
        2. mystyle.css
          0.1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            chetankjain chetankjain
            Votes:
            7 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes