QNetworkAccessManager :: get()性能不佳

时间:2013-03-16 16:47:48

标签: c++ performance qt networking

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";
}

1 个答案:

答案 0 :(得分:0)

好吧,谷歌有时会在很长一段时间内为我的应用返回该页面。任何其他网页加载速度都非常快。