I using the QChartView to plot two-line series.Capture.jpg
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?
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);
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;
}
QImage img((chartView->size()), QImage::Format_ARGB32);
QPainter painter;
painter.begin(&img);
chartView->render(&painter);
painter.setRenderHint(QPainter::Antialiasing);
painter.end();
img.save(path);
To copy to clipboard, switch view to plain text mode
Bookmarks