Thanks, seems to work pretty well. Started the app, and renamed the web page, and web server log shows the app is trying to get the web page every minute just like I want.
I'll test this for a while, and if this needs to be more reliable I'll follow your advice and implement my own slot, which uses loadFinished(bool ok) signal to check if the reload() slot was successful or not (since reload() returns nothing).
Again, thanks for good and fast answer, Volker!
-Paavo
PS I'll attach the modified source file in case somebody else needs similar thing; here the URL
is not so hard-coded, and there is even a bit silly error message if the URL is empty (or user
exits the QInputDialog::getText() with escape. Also added query for the reload interval.
@#include <QApplication>
#include <QWebView>
#include <QInputDialog>
#include <QErrorMessage>
#include <QTimer>
int main(int argc, char *argv[])
{
bool ret; QString text="http://an.example.com/weather/weather.php?scale=1.5";
QTimer timer; QApplication a(argc, argv); QWebView view; QErrorMessage error;
int i=QInputDialog::getInt(0 /* parent */,
"web page reloader (wpr)",
"Enter refresh interval (1-60 minutes)", 5, 1, 60, 1,
&ret, 0 /* window flags */);
text=QInputDialog::getText(0 /* parent */,
QObject::tr("Show web page - reload every %1 minute(s)").arg(i),
"Enter URL and press Enter to continue (or ESC to abort)",
QLineEdit::Normal, text, &ret, 0 /* window flags */);
if(ret && !text.isEmpty())
{
view.load(QUrl(text)); view.show(); /* or view.showMaximized(); */
QObject::connect(&timer, SIGNAL(timeout()), &view, SLOT(reload()));
timer.setInterval(i * 60 * 1000); /* milliseconds */ timer.start();
}
else
{
error.setFixedSize(400, 200); error.showMessage("Next time, then...");
}
return a.exec();
}@