如何将 QTextEdit 拆分为页面? [英] How to split QTextEdit into pages?

查看:247
本文介绍了如何将 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).

请注意 QTextDocument 类:

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

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

If the document is not paginated, like for example a document used in a QTextEdit, then a temporary copy of the document is created and the copy is broken into multiple pages according to the size of the paint device's paperRect().

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆