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

QSvgGenerator does not render QSvgIconEngine based icons

    XMLWordPrintable

Details

    Description

      QSvgGenerator does not render QSvgIconEngine based icons if they are drawn using QIcon::paint method. This seems to be a regression from Qt 5.8.1

      Example (from the attached project):

          QIcon icon_svg(":/test/input.svg");
          assert(!icon_svg.isNull());
          QPixmap icn_pix(icon_svg.pixmap(32));
          assert(!icn_pix.isNull());
          QSvgGenerator gen;
          gen.setViewBox(QRect(0, 0, 256, 256));
          QBuffer contents;
          gen.setOutputDevice(&contents);
          QPainter p(&gen);
      
          icon_svg.paint(&p, QRect(0, 0, 32, 32));  // This does not work ...
          p.drawPixmap(QRect(64, 0, 32, 32), icn_pix);  // ... but this does
      
          qDebug() << "devicePixelRatioF: " << p.device()->devicePixelRatioF() << "\n";
      
          p.end();
      
          qDebug() << QString::fromUtf8(contents.buffer());
      

      Note that QSvgGenerator has a very peculiar devicePixelRatioF of 1.52588e-05.
      This is probably the cause of this behavior because this value is multiplied into requested size by QSvgIconEngine::paint

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vgt Eirik Aavitsland
            aleserjavec Ales Erjavec
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes