Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make links clickable in a QTextEdit?

Is there a way to make links clickable in a 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.

Is this possible or am I stuck with having two separate widgets in a stack and switching between them?

like image 352
dF. Avatar asked Oct 16 '09 00:10

dF.


People also ask

How do I make a link clickable in text?

Enter the full address (including https) or file location you want the link to navigate to in the field, and press Enter. Now you have a link clickable in text.

Is it possible to add a qtextedit widget to a website?

If you find the HTML support insufficient for your needs you may consider the use of Qt WebKit, which provides a full-featured web browser widget. The shape of the mouse cursor on a QTextEdit is Qt::IBeamCursor by default.

How do I add a hyperlink to a text file?

Highlight the text you want to link. Click on the Add Link icon in the text editing bar (or Ctrl+K). Paste or type the URL you want to link to in the field and click “OK.” Now you have your hyperlink.

What does the text editor property document () do in Qt?

Setting this property makes the editor display a grayed-out placeholder text as long as the document () is empty. By default, this property contains an empty string. This property was introduced in Qt 5.2. See also document (). This property holds the text editor's contents as plain text.


1 Answers

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.

like image 101
Patrice Bernassola Avatar answered Sep 21 '22 12:09

Patrice Bernassola