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. Stroke width vector-effect="non-scaling-stroke" in generated SVG: problem is usually the SVG viewer
Forum Updated to NodeBB v4.3 + New Features

Stroke width vector-effect="non-scaling-stroke" in generated SVG: problem is usually the SVG viewer

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.9k Views 1 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.
  • B Offline
    B Offline
    bootchk
    wrote on last edited by
    #1

    This describes a problem/solution about stroke-width scaling in SVG generated by Qt. Qt sometimes generates the SVG property vector-effect="non-scaling-stroke" . Not all SVG viewers properly display this SVG generated by Qt . Recent viewers such as Firefox are proper, older viewers such as Image Viewer and Inkscape on Ubuntu are not proper.

    In this code, the two graphics items render properly in a QGraphicsView (to the display). In rendered svg, the stroke width of the second is huge, DEPENDING ON THE SVG VIEWER.
    The first item is created by the convenience function addRect(), and displays properly in older SVG viewers.
    The second item is a unit rect, scaled, and displays properly only in recent SVG viewers.
    In older viewers, it displays with a huge stroke-width and looks liked a filled rect with mangled corners.

    @
    # Non-unit rect
    self.addRect(10, 10, 20, 20, pen=QPen(Qt.red))

        # Scaled unit rect
        item = QGraphicsRectItem(0,0,1,1)
        item.setPos(30,30)
        item.setScale(20)
        self.addItem(item)@
    

    The "problem" then is one with conformance to the SVG standard.

    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