title: QChart in a QTextDocument
body: <p>I want to generate a pdf report containing text and a QChart. I currently use the QTextDocument and add the chart into it as an image, then I use the QPdfWriter to export to pdf. </p>
  
  <pre><code>#include &lt;QtGui&gt;
  #include &lt;QtCore&gt;
  #include &lt;QApplication&gt;
  #include &lt;QtCharts/QChartView&gt;
  #include &lt;QtCharts/QLineSeries&gt;
  using namespace QtCharts;
  
  int main(int argc, char *argv[])
  {
  QApplication a(argc, argv);
  
  // Create a chart
  QLineSeries *series = new QLineSeries();
  series-&gt;append(0,0);
  series-&gt;append(1,1);
  QChart *chart = new QChart();
  chart-&gt;addSeries(series);
  chart-&gt;createDefaultAxes();
  chart-&gt;axisX()-&gt;setTitleText(QString("x [m]"));
  chart-&gt;axisY()-&gt;setTitleText(QString("y [m]"));
  chart-&gt;setTitle("Simple chart example");
  chart-&gt;resize(500,500);
  
  // Paint the chart into an image
  QImage img(500,500,QImage::Format_RGB32);
  QPainter painter(&amp;img);
  QChartView *chartView = new QChartView(chart);
  chartView-&gt;setRenderHint(QPainter::Antialiasing);
  chartView-&gt;show();
  chartView-&gt;render(&amp;painter);
  
  // Set up pdf writer
  QString filename = "myfile.pdf";
  QPdfWriter writer(filename);
  writer.setPageSize(QPagedPaintDevice::A4);
  
  // Create the document
  QTextDocument doc;
  QTextCursor cursor(&amp;doc);
  cursor.insertText(QString("some text\n"));
  cursor.insertImage(img);
  // Print the document
  doc.print(&amp;writer);
  
  return a.exec();
  }
  </code></pre>
  
  <p>Although it works, I would like to avoid converting the chart into an image because it messes up the image quality. Is there a way to do it?</p>