[英]PyQt5 set QTextEdit document margin (constantly)
I would like to set a permanent margin in QTextEdit.我想在 QTextEdit 中设置永久边距。 And I found out about
self.document().rootFrame()
.我发现了
self.document().rootFrame()
。 I tried to set the left and right margin, however, the placeholder text is not adapting the margin same with clearing the text using self.clear()
我试图设置左右边距,但是,占位符文本没有调整边距与使用
self.clear()
清除文本相同
Try setting QTextDocument::setDocumentMargin()
https://doc.qt.io/qt-5/qtextdocument.html#documentMargin-prop , which you can access by calling QTextEdit::document()
https://doc.qt.io/qt-5/qplaintextedit.html#document , or QTextEdit::setViewportMargins()
https://doc.qt.io/qt-5/qabstractscrollarea.html#setViewportMargins .尝试设置
QTextDocument::setDocumentMargin()
https://doc.qt.io/qt-5/qtextdocument.html#documentMargin-prop ,您可以通过调用QTextEdit::document()
https://doc.qt 来访问它。 io/qt-5/qplaintextedit.html#document或QTextEdit::setViewportMargins()
https://doc.qt.io/qt-5/qabstractscrollarea.html#setViewportMargins 。 I am not sure which one will work best in your case.我不确定哪一个最适合您的情况。 You need to try it.
你需要尝试一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.