Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C++ by lol ( 14 years ago )
#ifndef DOWNLOADITEM_H
#define DOWNLOADITEM_H
#include <QtCore>
#include <QtNetwork/QtNetwork>
#include <QDebug>
#include <QFile>
#include <QtGui>
#include <QString>
class downLoadItem : QMainWindow(QWidget *parent)
{
public:
downLoadItem(QString link);
QFile file;
QNetworkAccessManager *pNetManager;
public slots:
void slotReadyRead();
void slotError(QNetworkReply::NetworkError);
void slotFinished();
};
#endif // DOWNLOADITEM_H
// .cpp
#include <downLoadItem.h>
#include <QtCore>
downLoadItem::downLoadItem
{
pNetManager = new QNetworkAccessManager(this);
QNetworkRequest request;
request.setUrl(QUrl(link));
QNetworkReply *reply = pNetManager->get(request);
connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead()));
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(slotError(QNetworkReply::NetworkError)));
connect(reply, SIGNAL(finished()), this, SLOT(slotFinished()));
file.setFileName("lost.avi");
file.open(QIODevice::WriteOnly);
}
void downLoadItem::slotError(QNetworkReply::NetworkError)
{
}
void downLoadItem::slotFinished()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
file.close();
reply->deleteLater();
}
void downLoadItem::slotReadyRead()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
file.write(reply->readAll());
}
Revise this Paste
Parent: 22552