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. [5.0.2] Qt SVG - rendering problem with <image> element
Forum Updated to NodeBB v4.3 + New Features

[5.0.2] Qt SVG - rendering problem with <image> element

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.0k 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.
  • G Offline
    G Offline
    Guillaume21
    wrote on last edited by
    #1

    Hello,

    It's the first time I use Qt SVG and I'd like to show a SVG image on my window.

    My code:
    @QSvgRenderer svg(QString("image.svg"));
    QImage *qi = new QImage(76, 147, QImage::Format_ARGB32);
    QPainter *painter = new QPainter(qi);
    svg.render(painter);

    QPixmap qpm = QPixmap::fromImage(*qi);

    ui->label->setPixmap(qpm);
    ui->label->setFixedSize(76, 147);@

    It works like a charm!

    However, when I try to render SVG images with an "<image> element":http://tutorials.jenkov.com/svg/image-element.html inside, it doesn't render well:
    !http://img11.hostingpics.net/pics/986948mainwindow.png(SVG with <image> element in my Qt program)!

    The same SVG renders fine in Inkscape (SVG editor):
    !http://img11.hostingpics.net/pics/997759inkscape.png(Same SVG in Inkscape)!

    You can download the SVG file "here":http://pastebin.com/fsUwMZ3F.

    Is it a bug or am I doing something wrong?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Guillaume21
      wrote on last edited by
      #2

      Up.

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        Qt SVG only implements SVG Tiny specification. It will not work well for all SVG files. And since nobody is eager to fix the module, it is not at all likely that things will improve in the future.

        You can use SVG parser from QtWebKit, that one uses full SVG specs, but is harder to use and of course pulls in a big dependency.

        (Z(:^

        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