PYQT5:避免在Qlabel / Qplaintextedit中降低多个空间
在PYQT5中,Qlabel和QplaintExtedIt小部件似乎都缩小了多个空格。说如果我将标签文本设置为:“ ABC ABC ABC”
,则显示的文本为“ ABC ABC ABC”
。
显然,这是由于这些小部件正在使用的默认HTML格式而发生的。
有没有办法将这些小部件设置为显示原始文本的多个空间保持原始格式?
编辑:
Qlabel-我能够通过引入< pre>
标签来对其进行排序。谁能帮助qplaintextedit?
In PyQt5, both QLabel and QPlainTextEdit Widgets appear to shrink multiple whitespaces in to one. Say if I set the label text to: "abc abc abc"
, text shown is "abc abc abc"
.
Apparently, this is happening because of the default html formatting these widgets are using.
Is there a way to set these widgets to show the original text with multiple spaces keeping the original formatting ?
Edit:
QLabel- I was able to get this sorted by introducing <pre>
tags. Can anyone help with the QPlainTextEdit ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
qplaintextedit
类不会减少多个空格,并且根本不支持HTML(如名称所建议)。Qlabel
类也不会减少多个空格,除非您明确包含HTML标签(并且如果您无法避免,则可以简单地使用&lt; pre&gt;
在必要时使用)。但是,我怀疑您可能正在使用具有相对较窄的空间字符的可变宽度字体,因此显而易见的缩小实际上是虚幻的。如果您使用固定宽度字体,则幻觉应该消失。
The
QPlainTextEdit
class does not reduce multiple whitespace, and it does not support html at all (as is suggested by the name). TheQLabel
class also does not reduce multiple whitespace unless you explicitly include html tags (and if you can't avoid that, you can simply use<pre>
tags where necessary).However, I suspect you may be using a variable-width font that has relatively narrow space characters, so the apparent whitespace reduction is actually illusory. If you use a fixed-width font instead, the illusion should disappear.