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?

Qt Code:
  1. QString path = QFileDialog::getSaveFileName(this, tr("Save as image"), "", tr("Image (*.svg *.png);;All Files (*.*);;"));
  2. if (path.isEmpty()) {
  3. qDebug() << "USER DID NOT SELECT the PATH!!!!!";
  4. return;
  5. }
  6. QImage img((chartView->size()), QImage::Format_ARGB32);
  7. QPainter painter;
  8. painter.begin(&img);
  9. chartView->render(&painter);
  10. painter.setRenderHint(QPainter::Antialiasing);
  11. painter.end();
  12. img.save(path);
To copy to clipboard, switch view to plain text mode