QNetworkAccessManager not sending signal on finished



  • I have the code below, I watched with wireshark, and see the HTTP post request go to the server, I see the server respond with the proper JSON string, however, the signal finished is never triggered??!!
    Help!?
    In the constructor:

      nam = new QNetworkAccessManager();
      connect(nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(rfinished(QNetworkReply*)));
    
    void RegistrationIntro::GetServerNews()
    {
    	QString url = "http://www.myserver.com/top/zznewsofday.php";
    	
    	QUrlQuery postData;
    	postData.addQueryItem("cmd", "news");
    	postData.addQueryItem("uuid", "333");
    
    	QUrl serviceUrl = QUrl(url);
    
    	QNetworkRequest request(serviceUrl);
    
    	request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
    
    	nam->post(request, postData.toString(QUrl::FullyEncoded).toUtf8()); 
    
     //I see in wireshark proper cmd="news" uuid="333" being sent, and my json response of  {"news":"<center>Welcome to 2.0 </center>","TERMINATE":"0"}\r\n
    
    }
    
    //Yet this function is NEVER called...even after I see the proper response from the server come in?!
    void RegistrationIntro::rfinished(QNetworkReply *reply)
    {
    	if (reply->error() == QNetworkReply::NoError)
    	{
    		QByteArray qba=reply->readAll();
    		std::string str = qba.toStdString();
    	}
    	else
    	{
    		std::string err = reply->errorString().toStdString();
    	}
    }
    


  • OK, problem was my slot function was not under slots: in the .h file....


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.