Reputation: 171
I have a QWebView inside a QTabWidget, and I'd like to know how to get the URL of the web page you're currently on so that I can:
So far, my tabs simply display the first page they load (google.co.uk), but I don't know how to change the name to the current URL when the user clicks a link.
Is there a better way to show the tab name? Or shall I just split the URL and take the name from there?
Upvotes: 0
Views: 731
Reputation: 1
you can trigger from the loadFinished event for after a page is loaded
void LoginDialog::on_webViewLogin_loadFinished(bool arg1)
{
QUrl myurl = ui->webViewLogin->url(); // grab current webview url & show
//.... other declarations etc
messageBox.critical( 0, "Error", myurl.toString() );
}
Upvotes: 0
Reputation: 650
WebView {
id: webview
url: "google.co.uk"
onUrlChanged: {
console.log("WebView UrlChange: ", url);
}
}
Upvotes: 2
Reputation: 7804
view = new QWebView();
connect(view,SIGNAL(linkClicked(QUrl)),this,SLOT(urlchange(QUrl)));
void WebviewItem::urlchange(QUrl &url)
{
qDebug()<<"linkClicked in Qt "<<url;
}
Upvotes: 0