Qt 的矢量图形剪贴板格式

发布于 2024-08-16 23:28:15 字数 255 浏览 3 评论 0原文

我希望我的 Qt 应用程序能够以兼容的方式将简单的矢量图形保存到剪贴板。在 Windows 上,我希望能够将图形粘贴到 Microsoft Word 或 Powerpoint 中。在 Linux 上我想与 Open Office 兼容。

您会推荐哪种格式? Qt 可以简单地生成 EMF 吗? SVG 是一种选择吗?

更新:

我当前的计划是添加一段本机 win32 代码以在 Windows 上将图形渲染为 emf。此代码在 Linux 上不可用。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不弃不离 2024-08-23 23:28:15

QGraphicsView 类及其关联的帮助程序可以通过以下方式呈现为 QT 图元文件格式QPicture 类(您可以为其编写 EMF 转换器)、SVG通过 QSVGGenerator 类并通过 QPrinter。它还可以渲染为位图格式和各种其他目标。

AFAIK 它没有通用的“渲染到 EMF”工具 - 您必须写入其他内容(例如 QT 图元文件)并转换为 EMF。如果您只需要图形基元的子集,则可能只需要在转换器中支持该子集。否则,您可以使用 SVG,您可以通过 QSVGGenerator 直接从 QT 获取 SVG。

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.

尐籹人 2024-08-23 23:28:15

我在这里有一个生成 EMF 的 PyQt QPaintEngine 类:https://github。 com/jeremysanders/veusz/blob/master/document/emf_export.py。它使用 pyemf 库,但我认为移植到 C++ 相当容易。不幸的是,这些文件与 OpenOffice 不兼容,因为 OO 在 EMF 文件中的路径支持相当糟糕。它还将文本转换为所见即所得的路径。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文