PDA

View Full Version : signal/slot for a Qebview urlChanged event



budda
26th April 2011, 12:17
this is a silly question, that most likely has an easy answer... but if I have a Qwebview called ui->webView... how do I connect the webview event as a signal and slot for a urlChanged()?

Zlatomir
26th April 2011, 12:42
You start by reading the signals and slots documentation (http://doc.qt.nokia.com/4.7/signalsandslots.html).

And then you will write something like:

connect(ui->webView, SIGNAL(urlChanged (QUrl) ), OBJECT_TO_CONNECT, SLOT(SLOT_TO_EXECUTE(QUrl)) );

//i don't know for sure if the correct parameter is QURL, check here (http://doc.qt.nokia.com/4.7-snapshot/qwebview.html)

budda
26th April 2011, 13:16
shouldn't this work if I have the checkForXLS(); as a PRIVATE SLOT: in the header file and a method for it as well?

connect(ui->webView, SIGNAL(urlChanged(QUrl url&)), this, SLOT(checkForXLS()));

Added after 6 minutes:



ui->setupUi(this);
ui->webView->load(QUrl("http://site.com/index.php"));
ui->webView->show();

//now put connection for checking class method if a changed url is actually a file with .xls extension
connect(ui->webView, SIGNAL(urlChanged(QUrl url&)), this, SLOT(checkForXLS()));



Added after 7 minutes:

Trying to download a file through the course of going through some webpages, I don't want to have a seperate QButton to download the file when it finally is sent to the QWebView, but a connection signal/slot to realize that it is a file with extension of .xls (already created) just need to trigger a method to start the QFileDialog::getSaveFileName() function... can this be a connection through the QWebView?

Added after 10 minutes:

I have used connection signals & slots before, but always with a ui->pushButton, a ui->action, or a ui->actionToolBar.... I guess my question is how to do this with a webView event?

budda
27th April 2011, 00:12
looks like I have to set up QNetworkAccessManager connection classes.....