1 Attachment(s)
Problem with saving QChartView as vector image file
I using the QChartView to plot two-line series.Attachment 13640
To save this graph, I am using the following code. Although it works fine when I save it as a .png file. However, when I try to save it as .svg format it doesn't do anything.
Can anybody tell me what might be the issue?
Code:
QString path
= QFileDialog::getSaveFileName(this, tr
("Save as image"),
"", tr
("Image (*.svg *.png);;All Files (*.*);;"));
if (path.isEmpty()) {
qDebug() << "USER DID NOT SELECT the PATH!!!!!";
return;
}
painter.begin(&img);
chartView->render(&painter);
painter.
setRenderHint(QPainter::Antialiasing);
painter.end();
img.save(path);
Re: Problem with saving QChartView as vector image file
Quote:
Can anybody tell me what might be the issue?
Have you included SVG support in your project? It isn't built-in like PNG.
The procedure for rendering SVG is not the same as rendering a pixmap image. Look at QSvgRenderer and QSvgGenerator and the SVG Generator example.