C++ (Qt)#ifndef DOWNLOADER_H#define DOWNLOADER_H #include <memory> #include <QObject>#include <QString>#include <QNetworkReply>#include <QNetworkRequest>#include <QNetWorkAccessManager> class Downloader : public QObject{ Q_OBJECT Downloader( ) {// connect( m_reply, SIGNAL( finished( ) ),// this, SLOT(replyFinished( ) ) ); } void fetch( const QString &url ) { std::shared_ptr<QNetworkAccessManager> manager( new QNetworkAccessManager( this ) ); m_reply = std::make_shared<QNetworkReply>( manager-> get( QNetworkRequest( QUrl( url ) ) ) ); //m_reply = manager->get( QNetworkRequest( QUrl( url ) ) ); } signals: void signalWithContent( QString * ); private slots: void replyFinished( ) { QByteArray data = m_reply->readAll( ); QString content( data ); emit signalWithContent( &content ); } private: std::shared_ptr<QNetworkReply> m_reply; //QNetworkReply *m_reply;}; #endif // DOWNLOADER_H
C++ (Qt)m_reply = std::make_shared<QNetworkReply>( manager->get( QNetworkRequest( QUrl( url ) ) ) );
C++ (Qt) QNetworkReply *m_reply; QNetworkAccessManager *manager = new QNetworkAccessManager( this ); m_reply = manager->get( QNetworkRequest( QUrl( url ) ) );
C++ (Qt) QNetworkReply *m_reply = new QNetworkReply( this );[code] [quote author=Old link=topic=27203.msg196820#msg196820 date=1403092573]28Observer8Что по вашему делает эта строка? [code=cpp]m_reply = std::make_shared<QNetworkReply>( manager->get( QNetworkRequest( QUrl( url ) ) ) );
C++ (Qt) QNetworkReply *m_reply = new QNetworkReply( this );
C++ (Qt)/*! Posts a request to obtain the contents of the target \a request and returns a new QNetworkReply object opened for reading which emits the \l{QIODevice::readyRead()}{readyRead()} signal whenever new data arrives. The contents as well as associated headers will be downloaded. \sa post(), put(), deleteResource(), sendCustomRequest()*/QNetworkReply *QNetworkAccessManager::get(const QNetworkRequest &request){ return d_func()->postProcess(createRequest(QNetworkAccessManager::GetOperation, request));}
C++ (Qt) m_reply = std::make_shared<???>( manager-> get( QNetworkRequest( QUrl( url ) ) ) );
m_reply.reset(manager->get( QNetworkRequest( QUrl( url ) ) ) );
C++ (Qt) std::shared_ptr<QNetworkReply> m_reply (manager->get( QNetworkRequest( QUrl( url ) ) ) );