C++ (Qt)QNetworkAccessManager *_qnam; void checkUpdatesFromUrl(const QUrl &url){ _qnam = new QNetworkAccessManager; connect(_qnam, SIGNAL(finished(QNetworkReply *)), SLOT(networkReplyFinished(QNetworkReply *))); _qnam->get(QNetworkRequest(url));} void networkReplyFinished(QNetworkReply *reply){ QByteArray webpage = reply->readAll(); reply->deleteLater(); _qnam->deleteLater(); QRegExp rx(QString("%1 v(.+)<\\/a>").arg(qApp->applicationName())); rx.setMinimal(true); if (rx.indexIn(webpage) != -1) { // всё ок - версия найдена } else { QUrl newUrl("сайт2"); if (newUrl != reply->url()) checkUpdatesFromUrl(newUrl); }}...checkUpdatesFromUrl("сайт1");
C++ (Qt)class O : public QObject{ Q_OBJECT public: O() : QObject() { qDebug("+O"); } ~O() { qDebug("-O"); }}; int main(int argc, char *argv[]){ QCoreApplication app(argc, argv); O *o; o = new O; o->deleteLater(); o = new O; o->deleteLater(); o = new O; o->deleteLater(); return app.exec();}
#include "main.moc"