本文介绍了如何将 QTextEdit 拆分为页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用来自 C++ Qt5 的 QTextEdit.我想在数字页面中正确拆分和显示富文本,类似于在 Microsoft Word 中的处理方式.我试过 document->setPageSize,但这对我不起作用 - 文本仍然显示在一个连续的页面中.

I'm using QTextEdit from C++ Qt5. I want to properly split and show rich text in numerated pages similarly to how it's done in Microsoft Word. I've tried document->setPageSize, however that does not work for me - text is still shown in one continuous page.

推荐答案

AFAIK QTextEdit 不支持字处理器风格的页面"概念.相反,QTextEdit 是围绕编辑和查看连续文档而设计的,其唯一的描述是在块"级别(即段落).

AFAIK QTextEdit doesn't support the word-processor-style concept of "pages". Rather, QTextEdit is designed around editing and viewing a continuous document, whose only delineation is at the level of "blocks" (i.e. paragraphs).

请注意 类:

Note this telling comment in the QTextDocument::print(QPagedPaintDevice *) const method-documentation of the QTextDocument class:

如果文档没有分页,例如在一个 QTextEdit,然后创建文档的临时副本并副本根据油漆的大小分成多页设备的 paperRect().

这篇关于如何将 QTextEdit 拆分为页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 19:26