Results 1 to 5 of 5

Thread: QSvgRenderer::boundsOnElement broken for text nodes

  1. #1
    Join Date
    Dec 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X

    Default QSvgRenderer::boundsOnElement broken for text nodes

    When calling boundsOnElement() on a text node QRectF(0,0 0x0) is always returned. I've searched around a bit, and can find one reference on a Yahoo group to this as well. I've tried a couple of different versions of Qt, but, am currently using 4.8.5 on a Mac.

    When calling this method for non-text nodes, it works correctly.

    Has anyone found a workaround for this?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSvgRenderer::boundsOnElement broken for text nodes

    Can you provide an example SVG document and the code that fails?

  3. #3
    Join Date
    Dec 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: QSvgRenderer::boundsOnElement broken for text nodes

    Your question implies there is an example that works.

    Here is a simple SVG and the code. The output is:
    Element exists: true
    Matrix: QMatrix(11=1 12=0 21=0 22=1 dx=0 dy=0)
    Local bounds: QRectF(0,0 0x0)
    Context bounds: QRectF(0,0 0x0)
    Element exists: true
    Matrix: QMatrix(11=1 12=0 21=0 22=1 dx=0 dy=0)
    Local bounds: QRectF(955.358,2445.36 7.28346x204.283)
    Context bounds: QRectF(955.358,2445.36 7.28346x204.283)
    Elapsed time: 2 milliseconds.


    QString fileName = "test.svg";
    QSvgRenderer * renderer = new QSvgRenderer(fileName, this);

    QString testID = "id1";
    qDebug() << "Element exists: " << renderer->elementExists(testID);
    QMatrix matrixOfElement = renderer->matrixForElement(testID);
    qDebug() << "Matrix: " << matrixOfElement;
    QRectF localBounds = renderer->boundsOnElement(testID);
    qDebug() << "Local bounds:" << localBounds;
    QRectF bounds = matrixOfElement.mapRect(localBounds);
    qDebug() << "Context bounds:" << bounds;

    testID = "id2";
    qDebug() << "Element exists: " << renderer->elementExists(testID);
    matrixOfElement = renderer->matrixForElement(testID);
    qDebug() << "Matrix: " << matrixOfElement;
    localBounds = renderer->boundsOnElement(testID);
    qDebug() << "Local bounds:" << localBounds;
    bounds = matrixOfElement.mapRect(localBounds);
    qDebug() << "Context bounds:" << bounds;


    test.svg.zip

    Thanks for any assistance.

  4. #4
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSvgRenderer::boundsOnElement broken for text nodes

    Anyone has answer on this?

    I am using Qt 4.8.1, and having exactly same problem, QSvgRenderer::boundsOnElement always return (0,0,0,0) for text node.

    Thanks

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSvgRenderer::boundsOnElement broken for text nodes

    https://bugreports.qt-project.org/browse/QTBUG-32405
    Fails here with Qt 4.8.5 and 5.1.1 on Linux. I cannot see an obvious cause.

Similar Threads

  1. QSvgRenderer crash
    By franki in forum Qt Programming
    Replies: 0
    Last Post: 20th June 2012, 14:36
  2. Replies: 1
    Last Post: 17th February 2011, 18:12
  3. QSvgRenderer not always working
    By BlandSauce in forum Newbie
    Replies: 3
    Last Post: 29th March 2010, 05:08
  4. About QSvgRenderer
    By guher in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 11:21
  5. QSvgRenderer::boundsOnElement returns incorrect QRectF
    By lfranchi in forum Qt Programming
    Replies: 8
    Last Post: 1st August 2007, 10:49

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.