Python 使用PySide链接到QLabel中的网页

Python 使用PySide链接到QLabel中的网页,python,hyperlink,pyside,qlabel,Python,Hyperlink,Pyside,Qlabel,我在使用PySide(Python版本3.2.5)在QLabel中显示指向网页的功能性超链接时遇到问题。读了这篇文章中投票率最高的答案后,我的印象是这样做是可行的: from PySide.QtCore import Qt from PySide.QtGui import QApplication, QLabel app = QApplication([]) window = QLabel() window.setText("<a href=\"http://stackoverflow.

我在使用PySide(Python版本3.2.5)在QLabel中显示指向网页的功能性超链接时遇到问题。读了这篇文章中投票率最高的答案后,我的印象是这样做是可行的:

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_()
从PySide.QtCore导入Qt
从PySide.QtGui导入QApplication、QLabel
app=QApplication([])
window=QLabel()
window.setText(“”)
window.setTextFormat(Qt.RichText)
window.setTextInteractionFlags(Qt.TextBrowserInteraction)
window.setOpenExternalinks(True)
window.show()
app.exec()

不幸的是,文本没有显示为链接。有人能给我指一下正确的方向吗?

你的链接断了,修复一下就可以了

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_()
从PyQt4.QtGui导入QApplication,QLabel
myQApplication=QApplication([])
myQLabel=QLabel()
myQLabel.setText(“”)
myQLabel.setOpenExternalinks(True)
myQLabel.show()
myQApplication.exec()

您的链接已断开,请修复它

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_()
从PyQt4.QtGui导入QApplication,QLabel
myQApplication=QApplication([])
myQLabel=QLabel()
myQLabel.setText(“”)
myQLabel.setOpenExternalinks(True)
myQLabel.show()
myQApplication.exec()

在本例中,
标记已自动关闭,因此没有链接文本。是;不知道这是怎么发生的,我想我只是复制粘贴了标签。。。很抱歉打扰您。在本例中,
标记已自动关闭,因此没有链接文本。是;不知道这是怎么发生的,我想我只是复制粘贴了标签。。。对不起,打扰你了。