C++ (Qt)void W::getPicture( const QUrl& url ){ static QNetworkAccessManager am; QNetworkRequest request( url ); QNetworkReply* reply = am.get( request ); connect( reply, SIGNAL(finished()), this, SLOT(slotRequestFinished()) );} void W::slotRequestFinished(){ QNetworkReply* reply = qobject_cast< QNetworkReply* >(sender() ); QPixmap pix( QImageReader( reply ).read() ); // label->setPixmap( pix ); reply->deleteLater();}
QIFormula.cpp: In member function ‘void QIFormula::getFormula(QString)’:QIFormula.cpp:30: error: no matching function for call to ‘QNetworkAccessManager::get(QNetworkRequest (&)(QUrl))’/opt/qtsdk-2010.05/qt/include/QtNetwork/qnetworkaccessmanager.h:116: note: candidates are: QNetworkReply* QNetworkAccessManager::get(const QNetworkRequest&)QIFormula.cpp: At global scope:QIFormula.cpp:27: warning: unused parameter ‘url’QIFormula.cpp: In member function ‘void QIFormula::slotRequestFinished()’:QIFormula.cpp:39: error: no matching function for call to ‘QPixmap::QPixmap(QImage)’/opt/qtsdk-2010.05/qt/include/QtGui/qpixmap.h:251: note: candidates are: QPixmap::QPixmap(const QSize&, int)/opt/qtsdk-2010.05/qt/include/QtGui/qpixmap.h:248: note: QPixmap::QPixmap(const QSize&, QPixmap::Type)/opt/qtsdk-2010.05/qt/include/QtGui/qpixmap.h:82: note: QPixmap::QPixmap(const QPixmap&)/opt/qtsdk-2010.05/qt/include/QtGui/qpixmap.h:80: note: QPixmap::QPixmap(const char* const*)/opt/qtsdk-2010.05/qt/include/QtGui/qpixmap.h:78: note: QPixmap::QPixmap(const QString&, const char*, Qt::ImageConversionFlags)/opt/qtsdk-2010.05/qt/include/QtGui/qpixmap.h:77: note: QPixmap::QPixmap(const QSize&)/opt/qtsdk-2010.05/qt/include/QtGui/qpixmap.h:76: note: QPixmap::QPixmap(int, int)/opt/qtsdk-2010.05/qt/include/QtGui/qpixmap.h:75: note: QPixmap::QPixmap(QPixmapData*)/opt/qtsdk-2010.05/qt/include/QtGui/qpixmap.h:74: note: QPixmap::QPixmap()
C++ (Qt)QPixmap pix( QPixmap::fromImage( QImageReader( reply ).read() ) );