Still nothing. Here's the code I'm using to try these things, on the chance that I'm doing it wrong:
Qt:
doc->setContent(str);
file->close();
doc->save(*bufStream, 0);
QXmlStreamReader *xmlReader = new QXmlStreamReader(buf);
std::cout << renderer->load(xmlReader) << std::endl;
item->setSharedRenderer(renderer);
scene->addItem(item);
buf->close();
QDomDocument *doc = new QDomDocument();
QGraphicsSvgItem *item = new QGraphicsSvgItem();
QFile *file = new QFile(":/assets/outline.svg");
file->open(QIODevice::ReadOnly);
QTextStream *stream = new QTextStream(file);
QString str = stream->readAll();
doc->setContent(str);
file->close();
QByteArray barr = doc->toByteArray();
QBuffer *buf = new QBuffer();
buf->open(QIODevice::ReadWrite);
QTextStream *bufStream = new QTextStream(buf);
doc->save(*bufStream, 0);
QXmlStreamReader *xmlReader = new QXmlStreamReader(buf);
QSvgRenderer *renderer = new QSvgRenderer();
std::cout << renderer->load(xmlReader) << std::endl;
item->setSharedRenderer(renderer);
scene->addItem(item);
buf->close();
To copy to clipboard, switch view to plain text mode
Here's the SVG file at various stages of the program:
String input from file (characters '\r' and '\n' formatted out for readability):
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="480px" height="360px" viewBox="0 0 480 360" enable-background="new 0 0 480 360" xml:space="preserve">
<path fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" d="M317.665,110.518c-13.627,0-26.354,3.846-37.165,10.5V29.5h-200v158h51.483l-18.221,86.857l74.429,66.658l94.942-31.128l12.747-60.766c6.866,2.212,14.184,3.419,21.785,3.419c39.219,0,71.012-31.793,71.012-71.012S356.884,110.518,317.665,110.518z"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="480px" height="360px" viewBox="0 0 480 360" enable-background="new 0 0 480 360" xml:space="preserve">
<path fill="#FFFFFF" stroke="#000000" stroke-miterlimit="10" d="M317.665,110.518c-13.627,0-26.354,3.846-37.165,10.5V29.5h-200v158h51.483l-18.221,86.857l74.429,66.658l94.942-31.128l12.747-60.766c6.866,2.212,14.184,3.419,21.785,3.419c39.219,0,71.012-31.793,71.012-71.012S356.884,110.518,317.665,110.518z"/>
</svg>
To copy to clipboard, switch view to plain text mode
Contents of QDomDocument via doc->toByteArray() (character '\n' formatted out for readability):
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg xmlns:xlink="http://www.w3.org/1999/xlink" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" x="0px" y="0px" height="360px" version="1.1" enable-background="new 0 0 480 360" width="480px" viewBox="0 0 480 360">
<path stroke-miterlimit="10" stroke="#000000" d="M317.665,110.518c-13.627,0-26.354,3.846-37.165,10.5V29.5h-200v158h51.483l-18.221,86.857l74.429,66.658l94.942-31.128l12.747-60.766c6.866,2.212,14.184,3.419,21.785,3.419c39.219,0,71.012-31.793,71.012-71.012S356.884,110.518,317.665,110.518z" fill="#FFFFFF"/>
</svg>
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg xmlns:xlink="http://www.w3.org/1999/xlink" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" x="0px" y="0px" height="360px" version="1.1" enable-background="new 0 0 480 360" width="480px" viewBox="0 0 480 360">
<path stroke-miterlimit="10" stroke="#000000" d="M317.665,110.518c-13.627,0-26.354,3.846-37.165,10.5V29.5h-200v158h51.483l-18.221,86.857l74.429,66.658l94.942-31.128l12.747-60.766c6.866,2.212,14.184,3.419,21.785,3.419c39.219,0,71.012-31.793,71.012-71.012S356.884,110.518,317.665,110.518z" fill="#FFFFFF"/>
</svg>
To copy to clipboard, switch view to plain text mode
Contents of the QBuffer (character '\n' formatted out for readability):
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg xmlns:xlink="http://www.w3.org/1999/xlink" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" x="0px" y="0px" height="360px" version="1.1" enable-background="new 0 0 480 360" width="480px" viewBox="0 0 480 360">
<path stroke-miterlimit="10" stroke="#000000" d="M317.665,110.518c-13.627,0-26.354,3.846-37.165,10.5V29.5h-200v158h51.483l-18.221,86.857l74.429,66.658l94.942-31.128l12.747-60.766c6.866,2.212,14.184,3.419,21.785,3.419c39.219,0,71.012-31.793,71.012-71.012S356.884,110.518,317.665,110.518z" fill="#FFFFFF"/>
</svg>
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg xmlns:xlink="http://www.w3.org/1999/xlink" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" x="0px" y="0px" height="360px" version="1.1" enable-background="new 0 0 480 360" width="480px" viewBox="0 0 480 360">
<path stroke-miterlimit="10" stroke="#000000" d="M317.665,110.518c-13.627,0-26.354,3.846-37.165,10.5V29.5h-200v158h51.483l-18.221,86.857l74.429,66.658l94.942-31.128l12.747-60.766c6.866,2.212,14.184,3.419,21.785,3.419c39.219,0,71.012-31.793,71.012-71.012S356.884,110.518,317.665,110.518z" fill="#FFFFFF"/>
</svg>
To copy to clipboard, switch view to plain text mode
Every SVG file looks like it has correct syntax, albeit with a bit of reorganizing with the attribute orders. Maybe there's something in it that the QSvgRenderer doesn't like?
Bookmarks