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


C++ QNetworkAccessManager::get方法代码示例

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


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

示例1: getSession

void LastFmLoginWidget::getSession()
{
    QString tempString = "api_key" + API_KEY + "methodauth.getsessiontoken" + TOKEN + SHARED_SECRET;
    QByteArray tempArray(tempString.toStdString().c_str());
    API_SIG = QString(QCryptographicHash::hash(tempArray,QCryptographicHash::Md5).toHex());
    getSessionUrl = QUrl("http://ws.audioscrobbler.com/2.0/?method=auth.getsession&token=" + TOKEN + "&api_key=" + API_KEY + "&api_sig=" + API_SIG);
    qDebug()<< getSessionUrl.toString()+" <-SESSION URL";
    QNetworkAccessManager *manager = new QNetworkAccessManager();
    QNetworkReply *reply = manager->get(QNetworkRequest(getSessionUrl));
    QEventLoop wait;
    connect(manager,SIGNAL(finished(QNetworkReply*)),&wait,SLOT(quit()));
    connect(manager,SIGNAL(finished(QNetworkReply*)), manager, SLOT(deleteLater()));
    //one take is gonna be 10sec
    QTimer oneTake;
    oneTake.start(10000);
    connect(&oneTake,SIGNAL(timeout()),&wait,SLOT(quit()));
    wait.exec();
    //finally get the reply
    QByteArray byteArrayToken = reply->readAll();
    reply->deleteLater();
    //parse xml response
    QXmlStreamReader xmlReader;
    xmlReader.addData(byteArrayToken);
    while (!(xmlReader.name().toString()=="key"))
        xmlReader.readNext();
    SESSION_KEY = xmlReader.readElementText();
    qDebug()<< SESSION_KEY+" <-SESSION HASH";
}
开发者ID:imandy420,项目名称:vkdesktopmusicplayer,代码行数:28,代码来源:lastfmloginwidget.cpp

示例2: StartSearch

void TitleIdFinder::StartSearch()
{
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
    QUrl url("http://marketplace.xbox.com/en-US/Search?query=" + gameName + "&DownloadType=Game");
    manager->get(QNetworkRequest(url));
}
开发者ID:Overx,项目名称:Velocity,代码行数:7,代码来源:titleidfinder.cpp

示例3: test_answer

void Authorization::test_answer(QNetworkReply *reply)
{
    QStringList html;
    while (!reply->atEnd())
        html << QString(reply->readLine());
    QPlainTextEdit *text = new QPlainTextEdit();
    text->appendPlainText(html.join('\n'));
    QStringList headers;
    QList<QByteArray> headerList = reply->request().rawHeaderList();
    foreach (QByteArray header, headerList)
        headers << QString(header+"\t"+reply->request().rawHeader(header));

    text->appendPlainText(headers.join('\n'));

    headerList = reply->rawHeaderList();
    foreach (QByteArray header, headerList)
        headers << QString(header+"\t"+reply->rawHeader(header));

    text->appendPlainText(headers.join('\n'));

    text->appendPlainText(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toString());
    text->appendPlainText(reply->errorString());
    text->show();

    if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 302) {
        QNetworkAccessManager *manager = new QNetworkAccessManager(this);
        QNetworkRequest request(QUrl(reply->rawHeader("Location")));
        request.setHeader(QNetworkRequest::CookieHeader, reply->header(QNetworkRequest::SetCookieHeader));
        manager->get(request);
        connect(manager, SIGNAL(finished(QNetworkReply*)), SLOT(test_answer(QNetworkReply*)));
        connect(manager, SIGNAL(finished(QNetworkReply*)), manager, SLOT(deleteLater()));
    }
}
开发者ID:codingworkshopru,项目名称:qt-projects,代码行数:33,代码来源:authorization.cpp

示例4: setWindowTitle

//-------------------------------------------------------------------------------
void MainWindow::on_pushButton_2_clicked()//заполнение
{
    //проверка урл
    if(ui->webView->page()->mainFrame()->url().toString()!="http://free-filmy.ru/addnew.html")
    {
        QMessageBox *nm=new QMessageBox;
        nm->setText("Перейдите на страницу добавления фильмов");
        nm->exec();
        delete nm;
        return;
    }
    setWindowTitle("получаем фильм ");

    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    connect(manager, SIGNAL(finished(QNetworkReply*)),this, SLOT(replyFinished(QNetworkReply*)));
    manager->get(QNetworkRequest(QUrl("http://"+ServIP+":3540/?dajfilm=true")));

     //подготовка формы
     ui->webView->page()->mainFrame()->evaluateJavaScript("document.getElementById('category').selectedIndex=-1");
     ui->webView->page()->mainFrame()->evaluateJavaScript("document.getElementsByTagName('select')[10].selectedIndex=1");
     ui->webView->page()->mainFrame()->evaluateJavaScript("document.getElementById('load_pc').style.display='none'");
     ui->webView->page()->mainFrame()->evaluateJavaScript("document.getElementById('load_url').style.display=''");
     ui->webView->page()->mainFrame()->evaluateJavaScript("document.getElementsByTagName('select')[0].selectedIndex=1");
     ui->webView->page()->mainFrame()->evaluateJavaScript("document.getElementById('l_pc').style.display='none'");
     ui->webView->page()->mainFrame()->evaluateJavaScript("document.getElementById('l_url').style.display=''");
     ui->webView->page()->mainFrame()->evaluateJavaScript("document.entryform.screen.value=''");
}
开发者ID:ksand77,项目名称:freeclient,代码行数:28,代码来源:mainwindow.cpp

示例5: checkForUpdates

void MainWindow::checkForUpdates()
{
    ui->lbl_updt_availability->setText("");
    //on télécharge le fichier texte qui contient la version
    QNetworkAccessManager *manager = new QNetworkAccessManager();
    manager->get(QNetworkRequest(QUrl("http://maj.outadoc.fr/freestance/version.txt")));
    QObject::connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(checkUpdatesResult(QNetworkReply *)));
}
开发者ID:outadoc,项目名称:FreeStance-desktop,代码行数:8,代码来源:mainwindow.cpp

示例6: getLiveVideoUrl

void YouTube::getLiveVideoUrl(const QString &videoId) {
    QString playerUrl = "http://www.youtube.com/get_video_info?&video_id=" + videoId + "&el=detailpage&ps=default&eurl=&gl=US&hl=en";
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    QNetworkRequest request;
    request.setUrl(QUrl(playerUrl));
    connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(parseLiveVideoPage(QNetworkReply*)));
    manager->get(request);
}
开发者ID:cuiboand1,项目名称:ytd-meego,代码行数:8,代码来源:youtube.cpp

示例7: getstops

bool SL::getstops(QString str) {
    QNetworkAccessManager * manager = new QNetworkAccessManager(this);
    connect(manager, SIGNAL(finished(QNetworkReply*)),
            this, SLOT(parsestops_json(QNetworkReply*)) );
    manager->get(QNetworkRequest(QUrl(nameaddress + removespecials_sl_skane(str))));
    qDebug()<<"NAMEADDRESS::"<<(nameaddress+removespecials_sl_skane(str));
    return true;
}
开发者ID:sebiva,项目名称:travelplanner,代码行数:8,代码来源:sl-old.cpp

示例8: sendPlaylistRequest

void ApiComponent::sendPlaylistRequest(const QString &request)
{
    QNetworkAccessManager * networkManager = new QNetworkAccessManager(this);
    connect(networkManager, &QNetworkAccessManager::finished, this, &ApiComponent::getPlaylistFromReply);
    QNetworkRequest networkRequest(request);

    QNetworkReply *reply = networkManager->get(networkRequest);
}
开发者ID:mefest,项目名称:flow,代码行数:8,代码来源:apicomponent.cpp

示例9: load

void OpdsBookModel::load(const QUrl &source)
{
    QNetworkAccessManager *manager = qmlEngine(QObject::parent())->networkAccessManager();

    QNetworkRequest request(source);
    QNetworkReply *reply = manager->get(request);
    connect(reply, &QNetworkReply::finished, this, &OpdsBookModel::onReplyFinished);
}
开发者ID:euroelessar,项目名称:cutereader,代码行数:8,代码来源:opdsbookmodel.cpp

示例10: run

void Updater::run()
{
    QNetworkAccessManager *webManager = new QNetworkAccessManager();
    connect(webManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*)));

    QNetworkRequest request(URL_UPDATE_SERVER);
    webManager->get(request);
}
开发者ID:pmuralikrishna111,项目名称:RemoteControlServer,代码行数:8,代码来源:updater.cpp

示例11: url

ScriptEngine::ScriptEngine(const QUrl& scriptURL,
                           AbstractControllerScriptingInterface* controllerScriptingInterface)  :
    _scriptContents(),
    _isFinished(false),
    _isRunning(false),
    _isInitialized(false),
    _engine(),
    _isAvatar(false),
    _avatarIdentityTimer(NULL),
    _avatarBillboardTimer(NULL),
    _timerFunctionMap(),
    _isListeningToAudioStream(false),
    _avatarSound(NULL),
    _numAvatarSoundSentBytes(0),
    _controllerScriptingInterface(controllerScriptingInterface),
    _avatarData(NULL),
    _scriptName(),
    _fileNameString(),
    _quatLibrary(),
    _vec3Library(),
    _uuidLibrary(),
    _animationCache(this)
{
    QString scriptURLString = scriptURL.toString();
    _fileNameString = scriptURLString;

    QUrl url(scriptURL);

    // if the scheme length is one or lower, maybe they typed in a file, let's try
    const int WINDOWS_DRIVE_LETTER_SIZE = 1;
    if (url.scheme().size() <= WINDOWS_DRIVE_LETTER_SIZE) {
        url = QUrl::fromLocalFile(scriptURLString);
    }

    // ok, let's see if it's valid... and if so, load it
    if (url.isValid()) {
        if (url.scheme() == "file") {
            QString fileName = url.toLocalFile();
            QFile scriptFile(fileName);
            if (scriptFile.open(QFile::ReadOnly | QFile::Text)) {
                qDebug() << "Loading file:" << fileName;
                QTextStream in(&scriptFile);
                _scriptContents = in.readAll();
            } else {
                qDebug() << "ERROR Loading file:" << fileName;
                emit errorMessage("ERROR Loading file:" + fileName);
            }
        } else {
            QNetworkAccessManager* networkManager = new QNetworkAccessManager(this);
            QNetworkReply* reply = networkManager->get(QNetworkRequest(url));
            qDebug() << "Downloading included script at" << url;
            QEventLoop loop;
            QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
            loop.exec();
            _scriptContents = reply->readAll();
        }
    }
}
开发者ID:BrianPrz,项目名称:hifi,代码行数:58,代码来源:ScriptEngine.cpp

示例12: render

void RssFeedNode::render(Grantlee::OutputStream* stream, Grantlee::Context* c)
{
  QNetworkAccessManager *mgr = new QNetworkAccessManager(this);
  QUrl url(Grantlee::getSafeString(m_url.resolve(c)));
  QNetworkReply *reply = mgr->get(QNetworkRequest(url));
  QEventLoop eLoop;
  connect( mgr, SIGNAL( finished( QNetworkReply * ) ), &eLoop, SLOT( quit() ) );
  eLoop.exec( QEventLoop::ExcludeUserInputEvents );

  c->push();
  foreach(Grantlee::Node *n, m_childNodes) {
    if (!n->inherits(XmlNamespaceNode::staticMetaObject.className()))
      continue;
    Grantlee::OutputStream _dummy;
    n->render(&_dummy, c);
  }

  QXmlQuery query;
  QByteArray ba = reply->readAll();

  QBuffer buffer;
  buffer.setData(ba);
  buffer.open(QIODevice::ReadOnly);
  query.bindVariable("inputDocument", &buffer);
  QString ns;
  QHash<QString, QVariant> h = c->lookup("_ns").toHash();
  QHash<QString, QVariant>::const_iterator it = h.constBegin();
  const QHash<QString, QVariant>::const_iterator end = h.constEnd();
  for ( ; it != end; ++it ) {
    if (it.key().isEmpty()) {
      ns += QLatin1Literal( "declare default element namespace " ) + QLatin1Literal( " \"" ) + it.value().toString() + QLatin1Literal( "\";\n" );
    } else {
      ns += QLatin1Literal( "declare namespace " ) + it.key() + QLatin1Literal( " = \"" ) + it.value().toString() + QLatin1Literal( "\";\n" );
    }
  }
  query.setQuery(ns + "doc($inputDocument)" + Grantlee::getSafeString(m_query.resolve(c)).get());

  QXmlResultItems result;
  query.evaluateTo(&result);

  QXmlItem item(result.next());
  int count = 0;
  while (!item.isNull()) {
      if (count++ > 20)
        break;
      query.setFocus(item);
      c->push();
      foreach(Grantlee::Node *n, m_childNodes) {
        if (n->inherits(XmlNamespaceNode::staticMetaObject.className()))
          continue;
        c->insert("_q", QVariant::fromValue(query));
        n->render(stream, c);
      }
      c->pop();
      item = result.next();
  }
  c->pop();
}
开发者ID:hicknhack-software,项目名称:Qt-Grantlee,代码行数:58,代码来源:rssfeed.cpp

示例13: loadScpd

/* Calling this fuction causes http get request
    and creates a new QtUpnpServiceIntrospection instance each time.
    When the instance is created successfully, it will emit a signal notifying clients.
    Clients should delete this pointer by themselves.
    Don't call this fuction too much to waste network resources.
    Cache the pointer for following use.
*/
void QtUpnpServiceInfo::loadScpd()
{
    /* Get SCPD doc */
    QNetworkAccessManager *manager = m_context->httpClient();
    connect(manager, SIGNAL(finished(QNetworkReply*)),
             this, SLOT(scpdReceived(QNetworkReply*)));

    m_pendingRequest.append(manager->get(QNetworkRequest(QUrl(scpdUrl()))));
}
开发者ID:bytephone,项目名称:qupnp,代码行数:16,代码来源:qtupnpserviceinfo.cpp

示例14: start

void Source::start(QStringList &arguments) {
  Q_UNUSED(arguments)

  QNetworkAccessManager* accessManager = page()->networkAccessManager();
  QNetworkRequest request(page()->currentFrame()->url());
  reply = accessManager->get(request);

  connect(reply, SIGNAL(finished()), this, SLOT(sourceLoaded()));
}
开发者ID:Aupajo,项目名称:capybara-webkit,代码行数:9,代码来源:Source.cpp

示例15: searchBtn_Clicked

void MainWindow::searchBtn_Clicked()
{
    ui.searchBtn->setEnabled(false);
    QString url = ui.urlLineEdit->text().trimmed();
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    connect(manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replayFinished(QNetworkReply*)));

    manager->get(QNetworkRequest(url));
}
开发者ID:lzdbh,项目名称:qt-test,代码行数:9,代码来源:mainwindow.cpp


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