PyQt 如何添加链接到 QTextBrowser [英] PyQt how to add link to QTextBrowser

查看:46
本文介绍了PyQt 如何添加链接到 QTextBrowser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么我很难找到这个,但是你如何添加到 QTextEditQTextBrowser 的超链接?我正在尝试制作具有链接列表的内容,当您单击链接时,您将获得该链接所引用的对象.

I don't know why I'm having such a hard time finding this, but how do you add a hyperlink to QTextEdit or QTextBrowser? I'm trying to make something that has a list of links and when you click on a link you get the object that the link is referencing.

推荐答案

您需要将 acceptRichText 属性设置为 true.然后你可以使用 setHTML() 槽传入 HTML.

You need to set the acceptRichText property to true. Then you can just pass in HTML using the setHTML() slot.

win.setHTML("<a href="http://foo>Bar</a>");

这篇关于PyQt 如何添加链接到 QTextBrowser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆