title: writing images to .odf/.odt with QtTextDocumentWriter giving realy low quality output
body: <p>I'm handling some charts in my Qt application and need to output them to a .odf/.odt file. Found on Qt documentation about this <a href="https://doc.qt.io/qt-5/qtextdocumentwriter.html#write" rel="nofollow noreferrer">method</a>.</p>
  
  <p>I've implemented it by getting a QPixmap from the chart and then converting it to a Qimage that is written to the QTextDocument.
  When i open the output document my charts are realy blurry, seems like a bad compression or something is happening.</p>
  
  <p>What did i get wrong about handling .odf?</p>
  
  <p>If i try to use the same QTextDocument to write to a .pdf or in a QTextEdit seems to work fine. But realy need to get the final output to a .odf file so that's no good for me. <em>Actualy also a docx or similar could be fine</em>
  </p>
  
  <pre><code>//create a chart and return it as an image
  QImage getChartImage(foo) {
      //stuff that handles creating a (QChart *chart) from given foo data
  
      QChartView *chartView = new QChartView(chart);
      chartView-&gt;setRenderHint(QPainter::Antialiasing);
      chartView-&gt;resize(1000,750);
  
      QPixmap chartImage = chartView-&gt;grab();
      chartImage.save("test.png", "PNG");    //just for testing, here looks fine
      return chartImage.toImage();
  }
  </code></pre>
  
  <p>and then in my main</p>
  
  <pre><code>//in main
  Qimage chartImage = getChartImage(foo);
  
  //setting up document
  QTextEdit *editor = new QTextEdit;    //not needed, but this works too
  // if no editor should be: 
  //QTextDocument *document = new QTextDocument;
  QTextDocument *document = new QTextDocument(editor);
  QTextCursor cursor(document);
  
  //adding image to document
  document-&gt;addResource(QTextDocument::ImageResource, QUrl("my_img.png"), chartImage);
  QTextImageFormat imageFormat;
  imageFormat.setName("img1.png");
  cursor.insertImage(imageFormat);
  cursor.insertBlock();
  cursor.insertText("some random text!");
  
  //show on editor; not needed but works
  editor-&gt;setDocument(document);
  editor-&gt;setWindowTitle(QObject::tr("I should work fine!"));
  editor-&gt;resize(1000, 750);
  editor-&gt;show();
  
  //and here the bad output happens
  QString fileName = QFileDialog::getSaveFileName(nullptr,QObject::tr("Save File"),"output_file.odf",QObject::tr("Open Document ('''.odf)"));
  QTextDocumentWriter fileWriter (fileName);
  fileWriter.setFormat("odf");
  fileWriter.write(document);
  </code></pre>
  
  <p>Here you can see how the charts get's saved to the document and how it should actualy look like.</p>
  
  <p>blurry output on .odf</p>
  
  <p><a href="https://i.stack.imgur.com/lkpE0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lkpE0.png" alt="enter image description here"></a></p>
  
  <p>output on QTextEdit</p>
  
  <p><a href="https://i.stack.imgur.com/1X0v1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1X0v1.png" alt="enter image description here"></a></p>
  
  <p>saving the QPixmap as .png</p>
  
  <p><a href="https://i.stack.imgur.com/quuVz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/quuVz.png" alt="enter image description here"></a></p>
  
  <p>Any idea on how to fix this? Or maybe an other method that I can use?</p>