In plain code, a QLabel
can be made bold by something as simple as:
myLabel = QtGui.QLabel("<strong>My bold label!</strong>")
However, QtDesigner insists on using:
myLabel = QLabel('<html><head/><body><p><span style=" font-weight:600;">My bold label!</span></p></body></html>')
Is this actually necessary, or is it another case of a WYSIWYG editor being massively overzealous?
The extra markup will only be added if you use the Rich Text tab of the editing dialog. Your own markup will be preserved verbatim if you:
EDIT:
To answer the question of whether the full markup is strictly necessary: no, not really. According to the Qt docs on the Supported HTML Subset, it is compliant with the HTML 4 spec. So, as with any reasonably competent html-rendering engine, it should have no difficulty dealing with an html document containing only the fragment <strong>My bold label!</strong>
.