Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.3.2, 5.4.0 Beta, 5.4.0 RC
-
None
-
Windows 7 64bits
-
3e6a14168bfa1a8815baf28eba8eeff5e3a97a80
Description
The Google Suggest example doesn't work anymore, I thinkt it has nothing to do with the Qt 5.4 versions but to the XML return by google.
The code example is based on two informations "suggestion" and "num_queries" but obviously the webservice provides by Google and use in the example doesn't give the "num_queries" anymore :
http://google.com/complete/search?output=toolbar&q=test
void GSuggestCompletion::handleNetworkData(QNetworkReply *networkReply) { QUrl url = networkReply->url(); if (!networkReply->error()) { QStringList choices; QStringList hits; QByteArray response(networkReply->readAll()); QXmlStreamReader xml(response); while (!xml.atEnd()) { xml.readNext(); if (xml.tokenType() == QXmlStreamReader::StartElement) if (xml.name() == "suggestion") { QStringRef str = xml.attributes().value("data"); choices << str.toString(); } if (xml.tokenType() == QXmlStreamReader::StartElement) if (xml.name() == "num_queries") { QStringRef str = xml.attributes().value("int"); hits << str.toString(); } } showCompletion(choices, hits); } networkReply->deleteLater(); }
The code rely on the fact that both lists have the same number of elements, it's not true so no completer is displayed :
void GSuggestCompletion::showCompletion(const QStringList &choices, const QStringList &hits) { if (choices.isEmpty() || choices.count() != hits.count()) return; }