Qt处理文件格式

原地址 https://wiki.qt.io/Handling_Document_Formats

利用Qt程序处理文档格式,通常涉及到解析、编写文档或者向客户展示文档。这里介绍了一些Qt通用的处理方式以及一些注意事项。

1一般注意事项

1.1Qt自带富文本文档框架。

它围绕类QTextDocument展开,该类提供了文档的基于对象的基于框架的表示形式,该文档由块(子帧,段落,表,列表等)组成,这些块又可以包含样式化的文本片段的字符串。包括API,用于从HTML加载并保存到HTML和ODT(请参阅QTextDocumentWriter),以及用于通过QTextEdit向用户显示文档(以只读或交互式可编辑模式)。

1.2XML处理

许多现代文档格式都基于XML。因此,根据您希望执行的处理类型,使用Qt强大的XML处理类进行手动解析/编写可能是一个可行的选择。对于大多数用途,建议使用QtCore中可用的高效XML流式类。在某些情况下,来自QtXml模块的SAX和DOM类可能是有用的替代方法。如果您的应用程序需要在许多具有类似结构的文档上重复提取某些信息或进行某种转换,则QtXmlPatterns模块可能提供了一种优雅的解决方案。

2个别格式

有关如何在Qt应用程序中使用特定文档格式的信息/提示(由社区收集),请在下面的列表中单击格式的名称

可以处理PDF,WORD,HTML,XLS,PPT等详细信息如下

Text Documents

HTML .html .htm .xhtml  
PDF .pdf  
Microsoft Word .doc .docx (native format of Microsoft Word)
OpenDocument Text .odt (native format of OpenOffice/LibreOffice Writer, among others)
Rich Text Format .rtf (here referring specifically to Microsoft's "RTF" format, not rich text in general)
LaTeX .tex

Spreadsheets

Microsoft Excel .xls, .xlsx (native format of Microsoft Excel)
OpenDocument Spreadsheet .ods (native format of OpenOffice/LibreOffice Calc, among others)
comma-separated values .csv (simple file format that is widely supported by consumer, business, and scientific applications.)

Presentations

Microsoft PowerPoint .ppt, .pptx (native format of Microsoft Powerpoint)
OpenDocument Presentation .odp (native format of OpenOffice/LibreOffice Impress, among others)

Math/Formulae

MathML .mml  
OpenDocument Formula .odf (native format of OpenOffice/LibreOffice Math, among others)
LaTeX Math  
发布了85 篇原创文章 · 获赞 34 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/chyuanrufeng/article/details/103537436