Clicking QLabel should open a default web browser with URL link specified. It is not happening yet. Why? A second question. Would it be possible to override the default blue color of the Label's font with something else?
class Widget(QtGui.QWidget):
def __init__(self, *args):
QtGui.QWidget.__init__(self, *args)
vLayout=QtGui.QVBoxLayout(self)
self.setLayout(vLayout)
urlLink="<a href=\"http://www.google.com\">'Click this link to go to Google'</a>"
label=QtGui.QLabel(self)
label.setText(urlLink)
vLayout.addWidget(label)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
w = Widget()
w.show()
sys.exit(app.exec_())
The styling of the label's contents can be modified using the standard html syntax.
To automatically open external links:
label.setOpenExternalLinks(True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With