Issue
I am trying to display some html code in a QLabel. While the QLabel renders the html properly, the hyper link is actually not working and the image links just produce a missing icon picture rather than showing the image itself. I am guessing that this is a limitation of QLabel and I may need to resort to QWebView, but just wanted to check if I'm missing something?!
Here is an example:
import sys
from PySide.QtGui import *
app = QApplication([])
label = QLabel()
label.setText('''<p><a href="http://www.google.com">"Go to Google"</a></p>
<p><img src="http://www.google.co.nz/logos/2012/field_hockey-2012-hp.jpg"/></p>
<p><span style="font-size: 17px;"><br /></span></p>''')
label.show()
sys.exit(app.exec_())
Solution
QLabel is not a web browser, although it can display rich text using a subset of HTML markup. See the documentation.
If you want something to happen when the link is clicked, you need to use the linkActivated() signal. Or you can use the openExternalLink property.
Answered By - user362638
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.