How to paginate a QPlainTextEdit?

此生再无相见时 提交于 2019-12-01 13:16:58

Have a look at QTextDocument, which holds a (formatted) document that can be viewed and edited in a QTextEdit, and is page-aware.

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:

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

Something similar is also available if you refer the QPrintPreviewWidget source

You can use stylesheets to modify the look-and-feel of your QPlainTextDocument like you wan want.

Hope that helps

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