我想为QLabel文本的每个单词设置一种颜色。
我在解释器中看到了这个问题的解决方案:
from PyQt5 import Qt
app = Qt.QApplication([])
label = Qt.QLabel()
txt = '''<font color="red">Это</font><br>
<font color="green">Цветной</font><br>
<font color="blue">Текст</font><br>'''
label.setText(txt)
label.setFont(Qt.QFont("sefif",32))
label.resize(400,300)
label.show()
app.exec_()
但是我怎么能直接在Qt Designer中做到这一点呢?
选择一个小部件
QLabel。插入文字:
<font color="red">这是</font><br><font color="green">彩色</font><br><font color="blue">文本</font><br>并安装所需的
textFormat