Is there a way to make links clickable in a QTextEdit
?
有没有办法让QTextEdit中的链接可点击?
I know I can use a QTextBrowser
and connect to anchorClicked
but I'd rather keep the editing and viewing all in one widget, and have clickable links when I set the widget to read-only mode.
我知道我可以使用QTextBrowser并连接到anchorClicked但是我宁愿在一个小部件中保持编辑和查看,并且当我将小部件设置为只读模式时具有可点击的链接。
Is this possible or am I stuck with having two separate widgets in a stack and switching between them?
这是可能的还是我坚持在堆栈中有两个单独的小部件并在它们之间切换?
1 个解决方案
#1
15
Since QTextBrowser
inherits from QTextEdit
, you should use it and set the readOnly
property to false. Then you can change the style of the QTextBrowser as you want.
由于QTextBrowser继承自QTextEdit,因此您应该使用它并将readOnly属性设置为false。然后,您可以根据需要更改QTextBrowser的样式。
#1
15
Since QTextBrowser
inherits from QTextEdit
, you should use it and set the readOnly
property to false. Then you can change the style of the QTextBrowser as you want.
由于QTextBrowser继承自QTextEdit,因此您应该使用它并将readOnly属性设置为false。然后,您可以根据需要更改QTextBrowser的样式。