QT TextBrowser unable to open html page from within an HTML page
-
Hi everyone,
I am stuck on a problem for which I can't really seem to find a solution. So I have an HTML file (a.html) with a link to another HTML file (using a href="b.html"). I am launching a.html using textBrowser and that works. But on clicking on the link which should ideally launch page b.html, it gives me an error in the log: " Go to window eWindow::ContextHelp
Unable to detect a web browser to launch 'learn_ok.html' ". (screenshots below)The weird thing here is, the same page is working fine in QT 4.8 but has an issue in Qt 5.15 (the development platform is for a company I work for).
*Edit: For those looking for a solution, the way QT TextBrowser works is once you launch a page, any links inside of that page is heard by anchorClicked Signal. So define a connect property with signal listening to anchorClicked(QUrl) and on SLOT define a property to take the URL and launch it just the way first page was launched. So something like : connect(mp_Ui->textBrowser, SIGNAL(anchorClicked(QUrl)), this, SLOT(onAnchorClicked(QUrl))); and then define onAnchorClicked(QUrl) as:
void CContextHelpForm::onAnchorClicked(const QUrl& link)
{
ShowPage(link);
} -
@Christian-Ehrlicher NEw link is mentioned in the ahref tag of the html page.
@Athem said in QT TextBrowser unable to open html page from within an HTML page:
NEw link is mentioned in the ahref tag of the html page.
That's not the point...
You should connect anchorClicked(QUrl) to a slot and show the given url in your QTextBrowser. -
Make sure you did not enable 'openExternalLinks' and anchorClicked() to open the link by yourself if the normal way does not work.
-
Make sure you did not enable 'openExternalLinks' and anchorClicked() to open the link by yourself if the normal way does not work.
@Christian-Ehrlicher Thanks for the response. The 'openExternalLinks' is set to false as well as I removed anchorClicked(QUrl) but it still does not work.
-
@Christian-Ehrlicher Thanks for the response. The 'openExternalLinks' is set to false as well as I removed anchorClicked(QUrl) but it still does not work.
@Athem said in QT TextBrowser unable to open html page from within an HTML page:
as well as I removed anchorClicked(QUrl) but it still does not work.
I don't understand this. I said you should use this signal so you can open the html page by yourself.
-
@Athem said in QT TextBrowser unable to open html page from within an HTML page:
as well as I removed anchorClicked(QUrl) but it still does not work.
I don't understand this. I said you should use this signal so you can open the html page by yourself.
@Christian-Ehrlicher My bad. I meant, I am using it already but it does not open the link still.
-
@Christian-Ehrlicher My bad. I meant, I am using it already but it does not open the link still.
@Athem said in QT TextBrowser unable to open html page from within an HTML page:
but it does not open the link still.
Since your slot does not take a url - how should it open the new link?
-
@Athem said in QT TextBrowser unable to open html page from within an HTML page:
but it does not open the link still.
Since your slot does not take a url - how should it open the new link?
@Christian-Ehrlicher NEw link is mentioned in the ahref tag of the html page.
-
@Christian-Ehrlicher NEw link is mentioned in the ahref tag of the html page.
@Athem said in QT TextBrowser unable to open html page from within an HTML page:
NEw link is mentioned in the ahref tag of the html page.
That's not the point...
You should connect anchorClicked(QUrl) to a slot and show the given url in your QTextBrowser.