Link to a line in a QTextBrowser - qt

I'm trying to make an advanced find system. What i'm trying to do is to display in a QTextBrowser the line where the string that you're searching for and make it clickable. And for when you click it, it redirects you to that line.
How would this be possible?

You could simply use html anchor (<a href="...">) and connect to signal anchorClicked of QTextBrowser

Related

Using links inside QTextEdit

ALL,
If I have a QTextEdit with the bunch of text and will want to insert a hyperlink in this text somewhere, will I get a handling of this hyperlink for free or I will have to write some additional code to handle the hyperlink hovering/clicking?
TIA!
[EDIT]
What I mean to ask was - whether it is possible QTextEdit to recognize the hyperlink after typing www.google.com and pressing either Space Bar or Enter key, so that it becomes rendered appropriately.
I don't want my user to type < a href=.....
Thank you and sorry for the confusion.
[/EDIT]

Is it possible show a tree view in a tooltip in Qt?

Is it possible show a tree view in a tooltip in Qt? Or represent a tree view with a QString and then show it in a tooltip?
doc states:
The tip is a short piece of text reminding the user of the widget's function. It is drawn immediately below the given position in a distinctive black-on-yellow color combination. The tip can be any rich text formatted string.
Rich text displayed in a tool tip is implicitly word-wrapped unless specified differently with <p style='white-space:pre'>.
Then I would suggest the simplest way could be to use a nested HTML list, something like <ul><li>...<ul><li>...</ul>...</ul> that could be easy to get from your structure
I think you need create treeview dynamically and show it when user stop moving mouse.
Create widget containing QTreeView and name like ToolTipTree
Make TooltipTree to follow mouse
When user stop moving mouse, set ToolTipTree shown. I user move mouse again, hide ToolTipTree

PyQt how to add link to QTextBrowser

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

Qt4: QLabel -> QPixmap -> click to open URL

I have a QLabel without any text but with a QPixmap image. I can not figure out a way to open a url when the user clicks the image. I can not use text in QLabel here.
You don't need to put text in, but you do need to switch to either a subclassed label or to use a QPushButton instead. If you use a QPushButton (which is the easiest) then you can change the relief layout so it looks flat again (since the default button doesn't).
You could install an event filter on the label and filter for mouse press events. For an example, see my answer to a similar question.

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?
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.

Resources