I am able to write the contents into a file, but unable to write those contents in a variable. Whether it is possible of reading the contents directly to a variable rather than writing to a file and then reading??
Added after 1 29 minutes:
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(replyFinished(QNetworkReply*)));
QNetworkReply
*reply
= manager
->get
(QNetworkRequest
(QUrl("http://www.oczenterprise.com/support/firmware/MN0MTV660VYQ0BGL/release/12606")));
QObject::connect(reply,
SIGNAL(finished
()),
&loop,
SLOT(quit
()));
loop.exec();
QFile file("C:\\data.dat");
file.write(reply->readAll());
strbytes=reply->readAll();
file.close();
QFile ffile
("D:\\data.dat");
ffile.write(strbytes);
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(replyFinished(QNetworkReply*)));
QNetworkReply *reply= manager->get(QNetworkRequest(QUrl("http://www.oczenterprise.com/support/firmware/MN0MTV660VYQ0BGL/release/12606")));
QEventLoop loop;
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
loop.exec();
QFile file("C:\\data.dat");
file.open(QIODevice::WriteOnly);
file.write(reply->readAll());
QByteArray strbytes;
strbytes=reply->readAll();
file.close();
QFile ffile("D:\\data.dat");
ffile.open((QIODevice::WriteOnly));
ffile.write(strbytes);
To copy to clipboard, switch view to plain text mode
In this code, strbytes has nothing. I have used
strbytes=reply->readAll();
QByteArray strbytes;
strbytes=reply->readAll();
To copy to clipboard, switch view to plain text mode
Bookmarks