#ifndef QREPLYTIMEOUT_H #define QREPLYTIMEOUT_H #include #include #include #include class QReplayTimeout : public QObject { Q_OBJECT public: QReplayTimeout(QNetworkReply *reply, const int timeout) :QObject(reply) { Q_ASSERT(reply); if( reply && reply->isRunning()){ QTimer::singleShot(timeout,this,SLOT(onTimeout())); } } signals: void net_timeout(); private slots: void onTimeout(){ QNetworkReply *reply = static_cast(parent()); if(reply->isRunning()){ reply->abort(); reply->deleteLater(); emit net_timeout(); } } }; #endif // QREPLYTIMEOUT_H