Hi protocole, I encouter the same issue as you, stole your code and made some modifies, now it works for me....
#include <QApplication>
#include <QLabel>
#include <QtNetwork/QNetworkAccessManager>
#include <QUrl>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
static QNetworkReply *reply;
class TOOTLabel
: public QLabel{
Q_OBJECT
public:
public slots:
void TOOTReadyRead()
{
img.load(reply, "JPEG");
setPixmap
(QPixmap::fromImage(img
));
show();
resize(img.width(),img.height());
}
};
int main(int argc, char **argv)
{
QNetworkAccessManager manager;
QNetworkRequest request;
request.
setUrl(QUrl("http://www.google.com/intl/en_ALL/images/logo2.gif"));
reply = manager.get(request);
TOOTLabel imgLabel;
QObject::connect( reply,
SIGNAL(finished
()),
&imgLabel,
SLOT(TOOTReadyRead
()));
return app.exec();
}
#include "main.moc"
#include <QApplication>
#include <QLabel>
#include <QtNetwork/QNetworkAccessManager>
#include <QUrl>
#include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply>
static QNetworkReply *reply;
class TOOTLabel : public QLabel
{
Q_OBJECT
public:
TOOTLabel(QWidget *parent =0) : QLabel(parent) {}
public slots:
void TOOTReadyRead()
{
QImage img ;
img.load(reply, "JPEG");
setPixmap(QPixmap::fromImage(img));
show();
resize(img.width(),img.height());
}
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QNetworkAccessManager manager;
QNetworkRequest request;
request.setUrl(QUrl("http://www.google.com/intl/en_ALL/images/logo2.gif"));
reply = manager.get(request);
TOOTLabel imgLabel;
QObject::connect( reply, SIGNAL(finished()), &imgLabel, SLOT(TOOTReadyRead()));
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks