title: QGraphicsScene to HTML?
body: <p>Using Qt, I am working on a tool that displays items in a <code>QGraphicsScene</code>. Items are both polygons and <code>QGraphicsTextItems</code>. The latter can contain hyperlinks.</p>
  
  <p><em>Problem</em>: I am trying to export the diagrams and I would like to keep the hyperlinks active.</p>
  
  <p>Using <code>QImage</code> renderers produce nice PNG but (obviously) no hyperlinks.
  <code>QSvgRenderer</code> produce SVG that also do not embed the hyperlinks.</p>
  
  <p><code>QPrinter</code> allows to generate PDF that do the job (more or less) - hyperlinks <em>are</em> clickable, and that is what I need in principle. Except that I want to publish the diagram on the web, so PDF is not really an option for me.</p>
  
  <p>I could not find any way render the <code>QGraphicsScene</code> in an HTML form. Did I miss something?  Is there a way to do that?</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>A code example:</p>
  
  <pre><code>from PySide import QtGui, QtCore
  app = QtGui.QApplication([])
  
  scene = QtGui.QGraphicsScene()
  view = QtGui.QGraphicsView(scene)
  
  item = QtGui.QGraphicsTextItem()
  item.setOpenExternalLinks(True)
  item.setHtml('&lt;a href="http://stackoverflow.com"&gt;Hello&lt;/a&gt;')
  item.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse)
  
  scene.addItem(item)
  
  view.show()
  app.exec_()
  </code></pre>
  
  <p>This example displays a scene with a clickable hyperlink (that opens the link with the default system application). In my application the scene also contains some graphical item but I think this is sufficient to get the idea: I would like to have this scene rendered (or printed or exported) in HTML so that the links would remain clickable.</p>
  
  <p>The following code does the export to PDF:</p>
  
  <pre><code>pdf_printer = QPrinter()
  pdf_printer.setOutputFormat(QPrinter.PdfFormat)
  pdf_printer.setPaperSize(rect.size().toSize(), QPrinter.Point)
  pdf_printer.setFullPage(True)
  pdf_printer.setOutputFileName(filename)
  pdf_painter = QPainter()
  pdf_painter.begin(pdf_printer)
  scene.render(pdf_painter, source=rect)
  pdf_painter.end()
  </code></pre>
  
  <p>And the resulting PDF does contains the active hyperlinks - this is what makes me thinks that all the mechanics is there. I just cannot find a way to export in HTML instead of PDF.</p>