QTextBrowser::anchorClicked not emitted for external links?
-
It looks like it is only emitted for internal links. I have a slot attached to this signal which is called when an internal link is clicked, but it is not called for external links.
What I would like to do is to ask/prompt the user on a per-link basis if they want to open an external link. I have seen the forum topic "QTextBrowser::anchorClicked not emitted" from about two years ago, but I am using the standard
QTextBrowserand not a subclass of it.I know that I can set the
openExternalLinksproperty, but how to do it on a per-link basis if the signal is never emitted? -
Set openExternalLinks to false, connect to anchorClicked and then do your decision if you want to open the link or not there.
-
Set openExternalLinks to false, connect to anchorClicked and then do your decision if you want to open the link or not there.
@Christian-Ehrlicher Thanks, I've gotten that far by now, too. The problems I still have are these:
- I can set the
openExternalLinksproperty totruein the slot, but the user must click on the link once again in order to open the link; - Once I have set
openExternalLinksproperty totrue, the slot is never called again except for internal links.
I can live with this if necessary. I show the URL to each external link in the status bar, so maybe this is enough. But is there a better way? IOW, how do I open the external link and leave
openExternalLinksset tofalse? - I can set the
-
This is not what I wrote.
You should set openExternalLinks to false, connect to anchorClicked and when you then decide to open the link then simply call setSource with the url you want. -
This is not what I wrote.
You should set openExternalLinks to false, connect to anchorClicked and when you then decide to open the link then simply call setSource with the url you want.@Christian-Ehrlicher : When I call
setSourcewith the external URL after asking the user whether to open the link or not, and the user cklicks "OK", theQTextBrowserwidget shows a blank page and does not open the internet browser.Or am I missing something else? For example, is there a way of opening the external link without calling
setSource? -
OK, problem is solved ... after looking at the sources, I needed to call
QDesktopServices::openUrl()(which is whatQTextBrowserdoes) and additionallysetSource()with the existing source URL of the text browser in order to make it work (i.e. in order to avoid the blank page inQTextBrowser).Thanks to all!
-
The please mark the topic as solved :)
-
The please mark the topic as solved :)
@Christian-Ehrlicher Done (already)!