在 Qlabel 中添加文本
Add text in Qlabel
我正在向 Qlabel 中显示一条消息,我想附加这些消息:
if A>B:
text_1=('As<sub>min</sub>')
else:
text_1=(' ')
if A>C:
text_2=(' A>C')
else:
text_2=(' ')
self.ui.label.setText('message' + '\n' +text_1 + '\n' + text_2)
但是显示的消息是这样的
message
As<sub>min</sub>
A>C
而不是
留言
作为分钟
A>C
我的问题是当我尝试显示下标时,它没有显示
如果要换行而不是用于纯文本的“\n”,则必须使用 <br>
。
self.ui.label.setText("<br>".join(["message", text_1, text_2]))
我正在向 Qlabel 中显示一条消息,我想附加这些消息:
if A>B:
text_1=('As<sub>min</sub>')
else:
text_1=(' ')
if A>C:
text_2=(' A>C')
else:
text_2=(' ')
self.ui.label.setText('message' + '\n' +text_1 + '\n' + text_2)
但是显示的消息是这样的
message
As<sub>min</sub>
A>C
而不是
留言
作为分钟
A>C
我的问题是当我尝试显示下标时,它没有显示
如果要换行而不是用于纯文本的“\n”,则必须使用 <br>
。
self.ui.label.setText("<br>".join(["message", text_1, text_2]))