打印 QTextDocument 时自定义页码
我正在尝试打印 QTextEdit
的内容。为此,我使用QTextDocument::print(QPrinter*)
。这样做时,页码会自动添加到页面的右下角。
有什么方法可以改变它的格式/移动它/摆脱它吗?
谢谢。
I'm trying to print the content of a QTextEdit
. For that I'm using QTextDocument::print(QPrinter*)
. Doing that, a page number is automatically added at the right bottom of the page.
Is there any way to change its format / move it / get rid of it?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,这是硬编码到 Qt 中的,所以你无法更改它。
请查看 QTBUG-1688。在那里你可以看到这个事实已经被报道过,但他们似乎没有采取行动。所以我想你必须自己做。
As far as I know that is hard coded into Qt, so you can't change it.
Have a look at QTBUG-1688. There you see that this fact has already been reported, but they don't seem to work on it. So you will have to do it yourself, I think.
如果你需要的话,有办法。您可以使用
void QTextDocument::drawContents ( QPainter * p, const QRectF & rect = QRectF() )
使用此添加所需的页脚..显然这不是一个好的方法,但如果您需要的话肯定有,好好利用它。
不过我还没有尝试过。但它应该有效。
If you need that, there is an way. You can use
void QTextDocument::drawContents ( QPainter * p, const QRectF & rect = QRectF() )
Add your desired footer using this.. Obviously it isn't a good one but if you need it for sure, make use of it.
I haven't give a try though. But it should work.