Hello,
I want to add checkLatestVersion functionality to my program. My program will connect foo.com/bar.file and get the latestVersion and compares with currentVersion. If latestVersion is greater then currentVersion that it will give a message (there is a new version, download it) and then quit.
Here is my code:
Code:
void VersionChecker::checkVersion() { connect(versionHttp,SIGNAL(requestFinished(int,bool)),this,SLOT(versionHttpData(int,bool))); versionHttp>setHost("www.foo.com", 80); versionHttpRequestId = versionHttp->get("/bar/latest.txt"); } void VersionChecker::versionHttpData(int id, bool error) { if (id != versionHttpRequestId) { return; } if(error) { latestVersionString = "2.0.0.0"; return; } latestVersionString = versionHttp->readAll(); } { return latestVersionString; }
and how i use it:
Code:
VersionChecker *versionControl = new VersionChecker(); versionControl->checkVersion(); if(latestVersion != _PROGRAM_VERSION) { NewVersionAvailableDialog *newVersionDialog = new NewVersionAvailableDialog(); newVersionDialog->setModal(true); newVersionDialog->setAttribute( Qt::WA_DeleteOnClose ); newVersionDialog->show(); return a.exec(); } MainForm w; w.show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); return a.exec();
The problem is, the program runs, QHttp connects and gets the latest version but, while these are being MainWindow is shown. I dont want it to be shown. Firstly latestVersion control must be finished. If current version is the latest version, then MainWindow must shown, otherwise i want the program to quit.
How can I do that? Where's the problem?

