Issue
I have a label with an eternal link in it, that I would like to change the color from the default blue to white.
label = QtWidgets.QLabel("<a href='https://example.com'> My Link </a>")
label.setOpenExternalLinks(True)
I have tried three different methods and have found no further documentation to point me in the right direction, any guidance would be appreciated:
# None of these work
label.setStyleSheet("color: #ffffff")
label.setStyleSheet("a{color: #ffffff}")
label.setStyleSheet("QUrl{color: #ffffff}")
Solution
If you want to change the color you must use the style within the HTML:
color = QtGui.QColor("white")
label = QtWidgets.QLabel(
"<a href='https://example.com' style='color:{}'> My Link </a>".format(color.name())
)
Answered By - eyllanesc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.