Je suis très nouveau à la mûre et de travailler avec des cascades. J'ai implémenté une connexion HTTP simple (HTTP POST).BB Slot pas de tir pour la connexion Http
La réponse est problématique, parfois je suis la réponse est montré dans un toast, et parfois il ne montre simplement rien.
Voici le code:
void ApplicationUI::work(QString clgId){
QNetworkAccessManager connection;
QUrl url("http://abc.co.in/test/test.php");
//url.addQueryItem("parameter", "2");
//QNetworkRequest request(url);
QByteArray data;
data.append("test=1");
QNetworkReply *reply = connection.post(request, data);
connect(reply, SIGNAL(finished()), SLOT(postFinished()));
showToast("OK");/*If I comment this line. The postFinished() is not called*/
}
void ApplicationUI::postFinished(void){
showToast("PostFinished");
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
if (reply->error() == QNetworkReply::NoError){
// No error
QString result = reply->readAll();
showToast(result);
}
else{
// error occurred
int errorCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
qDebug() << errorCode << endl << reply->errorString();
showToast(reply->errorString());
}
reply->deleteLater();
}
void ApplicationUI::showToast(QString text) {
bb::system::SystemToast toast;
toast.setBody(text);
toast.killTimer(5);
toast.setPosition(bb::system::SystemUiPosition::BottomCenter);
toast.exec();
}
Je suis dans une solution à ce problème est, s'il vous plaît aider.
Juste pour clarifier, est le problème avec du pain grillé ou ne pas montrer la requête POST rien retour? Ce sont deux problèmes distincts. – onion