I can't seem to be able to figure out how to get this work.
I have a webview in my app, and I want every link clicked on it to open in the system's default browser. The app lets the user choose one from a list of URLs and displays a small description webpage of said url, which has a link to the actual website. I want this link to be opened in an external browser.
This is what I have, regarding the problem:
App.cpp:
webWidget = new QWebView(this);
webWidget->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
connect(webWidget,
SIGNAL(linkClicked
(const QUrl &)),
this,
SLOT(urlClicked
(const QUrl &)));
webWidget = new QWebView(this);
webWidget->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
connect(webWidget, SIGNAL(linkClicked (const QUrl &)), this, SLOT(urlClicked(const QUrl &)));
To copy to clipboard, switch view to plain text mode
void App
::urlClicked(QUrl & link
) {
qDebug() << link.toString();
}
void App::urlClicked(QUrl & link)
{
qDebug() << link.toString();
QDesktopServices::openUrl(link);
}
To copy to clipboard, switch view to plain text mode
and in App.h,the slot
void urlClicked
(QUrl & link
);
void urlClicked(QUrl & link);
To copy to clipboard, switch view to plain text mode
But since the QUrl never gets sent to the slot(the debug line doesn't print anything), I'm assuming I'm missing something, but haven't been able to figure out what it is.
Bookmarks