PyQt how to add link to QTextBrowser

喜欢而已 提交于 2019-12-11 07:19:52

问题


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.


回答1:


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>");



来源:https://stackoverflow.com/questions/10134107/pyqt-how-to-add-link-to-qtextbrowser

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!