Hello all,
I want to display a hyperlink in qt. For this i need to display the link for the url (as underlined text). I can achieve it easily using style sheets and the url can be opened with webbrowser module..

I want to get the clicked signal of the url. I tried the linkactivated signal with qlabel but with no luck.. Any ideas.. If you suggest QTextBrowser give me a code snippet???

Solved the issue using QTextBrowser.. Code snippet is here.. I've set the background color to the windows default..

self.textBrowser = QtGui.QTextBrowser(self.groupBox)
        self.textBrowser.setGeometry(QtCore.QRect(140, 90, 121, 31))
        self.textBrowser.setStyleSheet("background-color: rgba(0, 110, 74, 0);")
        self.textBrowser.setFrameShape(QtGui.QFrame.NoFrame)
        self.textBrowser.setObjectName("textBrowser")
        self.textBrowser.setOpenExternalLinks(True)

self.textBrowser.setHtml(QtGui.QApplication.translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><a href=\"https://www.google.com\"><span style=\" font-size:8pt; text-decoration: underline; color:#0000ff;\">Google</span></a></p></body></html>", None, QtGui.QApplication.UnicodeUTF8))

P.S: You should set the open external links as true.. otherwise it'll show document not found error..

But can u give me the code snippet for getting the default background color of the dialog to set it for other widgets???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.