当前位置: 首页>>代码示例>>C++>>正文


C++ QNetworkReply::setParent方法代码示例

本文整理汇总了C++中QNetworkReply::setParent方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkReply::setParent方法的具体用法?C++ QNetworkReply::setParent怎么用?C++ QNetworkReply::setParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QNetworkReply的用法示例。


在下文中一共展示了QNetworkReply::setParent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: start

void GagImageDownloader::start()
{
    // if there is still downloads ongoing when start() is called
    // there will be big problem since m_gagList will be replaced
    Q_ASSERT(m_replyHash.isEmpty());
    foreach (const GagObject &gag, m_gagList) {
        if (gag.imageUrl().isEmpty() && gag.gifImageUrl().isEmpty())
            continue;

        if (m_downloadGIF && !gag.isGIF()) {
            qWarning("GagImageDownloader::start(): Not GIF, skip");
            continue;
        }
        const QUrl downloadImageUrl = m_downloadGIF ? gag.gifImageUrl() : gag.imageUrl();

        QNetworkReply *reply = m_networkManager->createGetRequest(downloadImageUrl, NetworkManager::Image);
        // make sure the QNetworkReply will be destroy when this object is destroyed
        reply->setParent(this);
        m_replyHash.insert(reply, gag);
        connect(reply, SIGNAL(finished()), SLOT(onFinished()));
    }

    m_imagesTotal = m_replyHash.count();
    if (m_imagesTotal > 1) {
        emit downloadProgress(0, m_imagesTotal);
    } else if (m_imagesTotal == 1) {
        connect(m_replyHash.keys().first(), SIGNAL(downloadProgress(qint64, qint64)),
                this, SIGNAL(downloadProgress(qint64,qint64)));
    } else {
        emit finished();
    }
}
开发者ID:412b,项目名称:GagBook,代码行数:32,代码来源:gagimagedownloader.cpp

示例2: url

QGeoCodeReply *QGeoCodingManagerEngineQGC::reverseGeocode(const QGeoCoordinate &coordinate, const QGeoShape &bounds)
{
    Q_UNUSED(bounds)

    QNetworkRequest request;
    request.setRawHeader("User-Agent", m_userAgent);

    QUrl url(QStringLiteral("http://maps.googleapis.com/maps/api/geocode/json"));
    QUrlQuery query;
    query.addQueryItem(QStringLiteral("sensor"), QStringLiteral("false"));
    query.addQueryItem(QStringLiteral("language"), locale().name().left(2));
    query.addQueryItem(QStringLiteral("latlng"), QStringLiteral("%1,%2")
                       .arg(coordinate.latitude())
                       .arg(coordinate.longitude()));

    url.setQuery(query);
    request.setUrl(url);
    //qDebug() << url;

    QNetworkReply *reply = m_networkManager->get(request);
    reply->setParent(0);

    QGeoCodeReplyQGC *geocodeReply = new QGeoCodeReplyQGC(reply);

    connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished()));
    connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)),
            this, SLOT(replyError(QGeoCodeReply::Error,QString)));

    return geocodeReply;
}
开发者ID:420174953,项目名称:qgroundcontrol,代码行数:30,代码来源:QGeoCodingManagerEngineQGC.cpp

示例3: reexecuteQuery

void CommandDownloadFile::reexecuteQuery()
{
    Q_D(CommandDownloadFile);
    QNetworkRequest request( d->downloadUrl );
    setRequestAccessToken(request, session()->accessToken());
    QNetworkReply* reply = session()->networkManager()->get(request);
    reply->setReadBufferSize(d->bufferSize);
    connect(reply, SIGNAL(finished()), SLOT(requestFinished()));
    connect(reply, SIGNAL(readyRead()), SLOT(readyRead()));
    connect(reply, SIGNAL(downloadProgress(qint64,qint64)), SIGNAL(progress(qint64,qint64)));
    reply->setParent(this);
}
开发者ID:navrocky,项目名称:libQtGoogleDrive,代码行数:12,代码来源:command_download_file.cpp

示例4: addEngine

void SearchEnginesManager::addEngine(const QUrl &url)
{
    ENSURE_LOADED;

    if (!url.isValid()) {
        return;
    }

    qApp->setOverrideCursor(Qt::WaitCursor);

    QNetworkReply* reply = mApp->networkManager()->get(QNetworkRequest(url));
    reply->setParent(this);
    connect(reply, SIGNAL(finished()), this, SLOT(replyFinished()));
}
开发者ID:eyome,项目名称:QupZilla,代码行数:14,代码来源:searchenginesmanager.cpp

示例5: startLoginRequest

void ChatService::startLoginRequest()
{
    _buddylist_poll_timer->stop();
    
    qDebug() << _network->cookieJar()->cookiesForUrl(QUrl(FACEBOOK_URL)).count() << " cookies";
    QList<QNetworkCookie> cookies;
    
    QMap<QString, QString> params;
    QUrl url(FACEBOOK_LOGIN_URL);

    QNetworkCookie cookie;
    cookie.setDomain(".facebook.com");
    cookie.setPath("/");

    // facebook uses this cookie to test for cookie support
    // if we dont set it it thinks we don't support cookies.
    cookie.setName("test_cookie");
    cookie.setValue("1");
    cookies << cookie;

    cookie.setName("isfbe");
    cookie.setValue("false");
    cookies << cookie;

    _network->cookieJar()->setCookiesFromUrl(cookies, QUrl(FACEBOOK_URL));

    qDebug() << _network->cookieJar()->cookiesForUrl(QUrl(FACEBOOK_URL)).count() << " cookies";

    // it seems those are not really needed, until I figure what
    // are they for
    //params.insert("md5pass", "0");
    //params.insert("noerror", "1");

    params.insert("email", _login);
    params.insert("pass", _password);
    params.insert("persistent", "1");
    params.insert("login", "Login");
    params.insert("charset_test", "€,´,€,´,水,Д,Є");

    QString data = encodePostParams(params);
    qDebug() << data;

    QNetworkReply *reply = _network->post(QNetworkRequest(url), data.toAscii());
    reply->setParent(this);
    
    QObject::connect(reply, SIGNAL(finished()), this, SLOT(slotLoginRequestFinished()));
    QObject::connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(slotLoginRequestError(QNetworkReply::NetworkError)));
}
开发者ID:jriddell,项目名称:kopete-facebook,代码行数:48,代码来源:chatservice.cpp

示例6: reexecuteQuery

void CommandFileList::reexecuteQuery()
{
    Q_D(CommandFileList);

    QUrl url("https://www.googleapis.com/drive/v2/files");
    if (!d->query.isEmpty())
        url.addQueryItem("q", d->query);
    if (!d->fields.isEmpty())
        url.addQueryItem("fields", d->fields);
    //url.addQueryItem("maxResults","100");

    QNetworkRequest request(url);
    setRequestAccessToken(request, session()->accessToken());

    QNetworkReply* reply = session()->networkManager()->get(request);
    connect(reply, SIGNAL(finished()), this, SLOT(queryFinished()));
    reply->setParent(this);
}
开发者ID:danilovsergei,项目名称:keepassx-gdrive,代码行数:18,代码来源:command_file_list.cpp

示例7: reexecuteQuery

void CommandSetFileProperties::reexecuteQuery()
{
    Q_D(CommandSetFileProperties);


    QString urlStr("https://www.googleapis.com/drive/v2/files");

    if (!d->fileInfo.id().isEmpty())
        urlStr += QString("/%1/properties").arg(d->fileInfo.id());
    QUrl url(urlStr);
    QNetworkRequest request(url);
    setRequestAccessToken(request, session()->accessToken());

    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json; charset=UTF-8");

    Q_FOREACH (const QString& key,d->fields.keys()) {
        currentKey=key;
        QVariantMap fileInfoMap;
        fileInfoMap.insert(KEY_STRING,key);
        fileInfoMap.insert(VALUE_STRING,d->fields[key]);
        fileInfoMap.insert(VISIBILITY_STRING,"PUBLIC");
        QByteArray body = QJson::Serializer().serialize(fileInfoMap);

        QNetworkReply* reply = session()->networkManager()->post(request, body);


        connect(reply, SIGNAL(finished()), this, SLOT(queryFinished()));


        connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),SLOT(queryFailed(QNetworkReply::NetworkError)));

        reply->setParent(this);
    }




}
开发者ID:danilovsergei,项目名称:keepassx-gdrive,代码行数:38,代码来源:command_set_properties.cpp


注:本文中的QNetworkReply::setParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。