//构造函数
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
pixmap = new QPixmap;
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slot_replyFinished(QNetworkReply*)));
QNetworkRequest request;
request.setUrl(QUrl("http://img0.bdstatic.com/img/image/shouye/dengni63.jpg"));
manager->get(request);
}
//槽函数
void MainWindow::slot_replyFinished(QNetworkReply* reply)
{
QPixmap pix;
QByteArray data = reply->readAll();
pix.loadFromData(data, "JPG");
pix.save("c://tmp1.jpg", "JPG", 100);
ui->textEdit->append(" src=c://tmp1.jpg>");
}
|