Issue
I am having troubles displaying a functional hyperlink to a web page in a QLabel using PySide (Python version 3.2.5). Reading the most upvoted answer from this post c++ - Making QLabel behave like a hyperlink - Stack Overflow, I was under the impression that this would work:
from PySide.QtCore import Qt
from PySide.QtGui import QApplication, QLabel
app = QApplication([])
window = QLabel()
window.setText("<a href=\"http://stackoverflow.com/\" />Stack Overflow</a>")
window.setTextFormat(Qt.RichText)
window.setTextInteractionFlags(Qt.TextBrowserInteraction)
window.setOpenExternalLinks(True)
window.show()
app.exec_()
Unfortunately, the text does not show up as a link. Can anyone please point me in the right direction?
Solution
Your link are broken, Fix it should be fine;
from PyQt4.QtGui import QApplication, QLabel
myQApplication = QApplication([])
myQLabel = QLabel()
myQLabel.setText('''<a href='http://stackoverflow.com'>stackoverflow</a>''')
myQLabel.setOpenExternalLinks(True)
myQLabel.show()
myQApplication.exec_()
Answered By - Kitsune Meyoko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.