Qt
  1. Qt
  2. QTBUG-32405

QSvgRenderer::boundsOnElement broken for text nodes

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: P2: Important P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 4.8.5, 5.2.0
    • Fix Version/s: None
    • Component/s: Qt SVG
    • Environment:

      Mac OS X 10.8, Windows 7

      Description

      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.

      1. test.svg.zip
        0.8 kB
        Timothy Reaves
      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        Hide
        Timothy Reaves added a comment - - edited

        Sample code:

         
        	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;
        

        Output:

         
        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) 
        
        Show
        Timothy Reaves added a comment - - edited Sample code: 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; Output: 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)
        Hide
        Joerg Bornemann added a comment -

        QSvgText::bounds is not implemented.

        Show
        Joerg Bornemann added a comment - QSvgText::bounds is not implemented.
        Hide
        Wilbert Berendsen added a comment -

        This would be very nice to have fixed. I want to highlight certain elements of a Tiny SVG file, but I cant's use QSvgRenderer/Widget because of the missing implementation of QSvgText::bounds.

        This bug also relates to issue QTBUG-2002, which showcases the same issue.

        Show
        Wilbert Berendsen added a comment - This would be very nice to have fixed. I want to highlight certain elements of a Tiny SVG file, but I cant's use QSvgRenderer/Widget because of the missing implementation of QSvgText::bounds. This bug also relates to issue QTBUG-2002 , which showcases the same issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Timothy Reaves
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Gerrit Reviews

              There are no open Gerrit changes