0

QNetwotkAccessManages::get() 函数会持续一段时间(大约 7-10 秒),获取在任何浏览器中都可以立即打开的页面。

实际上,我尝试获取http://suggestqueries.google.com/complete/search?client=chrome&q=myrequest

这是简化的代码:

void ApiGoogleSearch::getSuggestions()
{
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    connect(manager, SIGNAL(finished(QNetworkReply*)),
            SLOT(getSuggestionsFinished(QNetworkReply*)));

    QUrl url("http://suggestqueries.google.com/complete/search"
             "?client=chrome&q=myrequest");
    manager->get(QNetworkRequest(url));
    qDebug() << "get() started";
}

void ApiGoogleSearch::getSuggestionsFinished(QNetworkReply *reply)
{
    qDebug() << "ApiGoogleSearch::getSuggestionsFinished() started";
}
4

1 回答 1

0

好吧,Google 不知何故会在很长一段时间内为我的应用返回该页面。任何其他网页加载都非常快。

于 2013-03-16T17:08:33.423 回答