Index: src/app/composer/qgscomposer.cpp =================================================================== --- src/app/composer/qgscomposer.cpp (revision 7801) +++ src/app/composer/qgscomposer.cpp (working copy) @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include #include @@ -773,9 +773,6 @@ void QgsComposer::on_mActionExportAsSVG_activated(void) { -// QT 4 QPicture does not support export to SVG, so we're still using Q3Picture. -// When QGIS moves to Qt 4.3, we can use QSvgGenerator instead. - QString myQSettingsLabel = "/UI/displaySVGWarning"; QSettings myQSettings; @@ -791,10 +788,9 @@ m->setCheckBoxQSettingsLabel(myQSettingsLabel); m->setMessageAsHtml(tr("

The SVG export function in Qgis has several " "problems due to bugs and deficiencies in the " - "Qt4 svg code. Of note, text does not " - "appear in the SVG file and there are problems " - "with the map bounding box clipping other items " - "such as the legend or scale bar.

" + "Qt4 svg code. In particular, there are problems " + "with layers not being clipped to the map" + "bounding box.

" "If you require a vector-based output file from " "Qgis it is suggested that you try printing " "to PostScript if the SVG output is not " @@ -822,20 +818,19 @@ mView->setScene(0);//don't redraw the scene on the display while we render mComposition->setPlotStyle ( QgsComposition::Print ); - Q3Picture pic; - QPainter p(&pic); - QRectF renderArea(0,0, (mComposition->paperWidth() * mComposition->scale()), (mComposition->paperHeight() * mComposition->scale()) ); + QSvgGenerator generator; + generator.setFileName(myOutputFileNameQString); + generator.setSize(QSize( (int)mComposition->paperWidth(), (int)mComposition->paperHeight() )); + generator.setResolution((int)(mComposition->resolution() / 25.4)); //because the rendering is done in mm, convert the dpi + QPainter p(&generator); + QRectF renderArea(0,0, mComposition->paperWidth(), mComposition->paperHeight()); mComposition->canvas()->render(&p, renderArea); p.end(); mComposition->setPlotStyle ( QgsComposition::Preview ); mView->setScene(mComposition->canvas()); //now that we're done, set the view to show the scene again - QRect br = pic.boundingRect(); - - pic.save ( myOutputFileNameQString, "svg" ); - }