Vector graphics clipboard format for Qt
Asked Answered
L

2

7

I want my Qt application to be able to save simple vector graphics to clipboard in a compatible way. On windows I want to be able to paste the graphics into Microsoft Word or Powerpoint. On Linux I want to be compatible with the Open Office.

Which format would you recommend? Can Qt generate EMF in an easy way? Is SVG an option?

Update:

My current plan is to add a piece of native win32 code to render the graphics to emf on windows. This code will not be available on linux.

Leitmotiv answered 25/10, 2008 at 16:13 Comment(0)
O
4

The QGraphicsView class and its associated helpers can render to a QT metafile format through the QPicture class (for which you could write a translator to EMF), to SVG through the QSVGGenerator class and to postscript/pdf through QPrinter. It can also render to bitmap formats and various other targets.

AFAIK it doesn't have a generic 'render to EMF' facility - you would have to write to something else like the QT Metafile and convert to EMF. If you only need a subset of the graphics primitives you might only need to support that subset in the translator. Otherwise you could go from SVG, which you can get directly from QT through QSVGGenerator.

Ornithischian answered 26/10, 2008 at 22:0 Comment(1)
I do not consider this to be an easy solution. Writing such a generic translator would take weeks. The EMF specs is 310 pages long. It would be much easier to generate EMF directly (only small subset of EMF is necessary).Leitmotiv
I
3

I have an EMF-generating PyQt QPaintEngine class here: https://github.com/jeremysanders/veusz/blob/master/document/emf_export.py. It uses the pyemf library, but I think it would be fairly easy to port to C++. Unfortunately the files are not compatible with OpenOffice as OO has pretty broken path support in EMF files. It also converts text to paths for WYSIWYG.

Isidor answered 29/6, 2011 at 13:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.