如何对 QPlainTextEdit 进行分页? [英] How to paginate a QPlainTextEdit?

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

问题描述

我一直在使用 QPlainTextEdit 在我们的应用程序中编辑文本.最近决定我们需要以分页格式显示文本,而不是一致的文本块.经过大量研究,我意识到虽然 QPlainTextEdit 对页面或分页没有任何了解,但 QPlainTextDocument 有.

I've been using QPlainTextEdit for editing text in our application. Recently it was decided that we need to display the text in a paginated format instead of a consistent block of text. After lots of research, I've come to the realization that while QPlainTextEdit does not have any knowledge of pages or pagination, QPlainTextDocument does.

听起来我们想要在内部进行分页,但我不知道如何修改 QPlainTextEdit 以在页面中显示文本而不是一个巨大的字段.

It sounds like internally we want to be doing the pagination, but what I can't figure out is how to modify QPlainTextEdit to show the text in pages instead of a gigantic field.

旁注:我知道这没关系,但我使用的是 qtruby,而不是普通的 Qt.

Side note: I know it doesn't matter but I am using qtruby, not plain Qt.

推荐答案

我最终在 Qt 论坛上重新提问:http://developer.qt.nokia.com/forums/viewthread/862

I ended up re-asking this on the Qt forums: http://developer.qt.nokia.com/forums/viewthread/862

他们给了我一个不错的主意,而且效果很好:

They gave me a decent idea which has worked pretty well:

如果你想喜欢的页面布局词,我看到的一种方式是……使用QGraphicsView,设置场景,设置多个 QGraphicsTextItems哪些是可编辑的,并更新任何编辑的整个文本..您可以设置QTextDocument 到这些文本项..

If you want like the page layout in word, one way I see is … using QGraphicsView, setting the scene, setting multiple QGraphicsTextItems which are editable, and updating the entire text on any edits.. you can set QTextDocument to these text items ..

类似的东西也可用,如果你指的是 QPrintPreviewWidget来源

Something similar is also available if you refer the QPrintPreviewWidget source

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

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