How to split QTextEdit into pages?

≯℡__Kan透↙ 提交于 2021-01-29 09:24:53

问题


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.


回答1:


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:

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().



来源:https://stackoverflow.com/questions/61840370/how-to-split-qtextedit-into-pages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!