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

QGraphicsWebView - incorrect boundingRect function for SVG image

    XMLWordPrintable

Details

    Description

      I have ported my app from QGraphicsSvgItem to QGraphicsWebView and encountered strange behaviour - my images got margins at left, top and bottom (8 pixels each). I conducted some tests and came to conclusion that WebKit is responsible for this bug.

      How to reproduce:

      test.pro
      QT += core webkitwidgets
      SOURCES += main.cpp
      
      main.cpp
      #include <QApplication>
      #include <QtWebKitWidgets/QGraphicsWebView>
      
      QByteArray svg = "\
      <svg\
        xmlns=\"http://www.w3.org/2000/svg\"\
        width=\"200\"\
        height=\"200\">\
        <g>\
          <rect\
            width=\"10\"\
            height=\"10\"\
            x=\"50\"\
            y=\"50\"\
            fill=\"#0000ff\"\
          />\
        </g>\
      </svg>";
      
      int main (int argc, char * argv[])
      {
        QApplication a (argc, argv);
        QGraphicsWebView w;
        w.setResizesToContents (true);
        w.setContent (svg);
        w.page()->setPreferredContentsSize (QSize (1, 1));
        QSizeF s = w.boundingRect().size();
        qDebug() << s.width() << s.height();
        return 0;
      }
      

      Output: 208 216, but should be 200 200

      Attachments

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

        Activity

          People

            annulen Konstantin Tokarev
            tapa Pavel
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes