PDA

View Full Version : webview event as a signal/slot for urlChanged



budda
26th April 2011, 12:48
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?

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?


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()));

AlexSudnik
26th April 2011, 13:21
QWebView does have a void urlChanged ( const QUrl & url ) signal,don't see any problems with using it. See docs for the details.

budda
27th April 2011, 00:10
looks like I'm trying to do more like a download manager using QNetworkAccessManager. Trying to a give a simple browser QT application a download file functionality. Like trying to combine the Qt/examples/network/http or the Qt/examples/network/downloadmanager program with the Qt/examples/webkit/fancybrowser program. I have some extensive php MySQL pages that saves a data array as a file called test.xls But the Qt program that is using a Qwebview to display all of this needs connection signal/slots to save a .xls file type. I see that doesn't work with the fancy browser example, but it works with the http program (even though it warns not to use that way of doing it) It does work with the Aurora Demo, but that's just an executeable demo.

budda
27th April 2011, 05:01
I went and bought the Advanced Qt Programming: Creating Great Software with C++ and Qt 4, by Mark Summerfield It nicely explains the above questions, but i'm only half way through reading it today...