在QTextEdit pyqt/pysid中预览外部图像

2024-09-22 16:24:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Python和PySide/PyQt4基于QTextEditor的WYSIWYG编辑器,我需要将来自网站的图像作为<img>标记插入其中,但它只是将其添加为小图标。在

插入图像的代码如下:

url = 'http://yoursportsfeeder.com/wp-content/uploads/2014/12/ap-patriots-ravens-football-720x400.jpg'
self.text.setHtml('<img src="%s" />' % url)

当执行这段代码时,我得到的图标如下图所示(只是一个白色的小图标)

enter image description here

我怎样才能得到图片预览?在


Tags: 代码标记图像comhttpurlimg网站