简体   繁体   中英

PyQt5 - Can I use different font sizes on different parts of the text in a label?

I would like to have a label where I have text with parts where the sizes are different. Is this possible with pyQT5 or some css.

PS: I haven't coded it and am more looking for the theoretical answer than code so I can't provide any code or such.

QLabel supports a limited HTML subset, and basic styling is still enabled:

self.label.setText('''
    normalText 
    <span style="font-size: 18px">biggerText</span>
    <span style="font-size: 24px">veryBigText</span>
''')

Read more about the Supported HTML Subset , which is valid for any rich-text enabled widgets (QLabel and all widgets that use a QTextDocument, like all QTextEdit descendants).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM