I solved the problem:

Qt Code:
  1. QNetworkReply * myNAM::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData){
  2. if(op==PostOperation) {
  3. QNetworkAccessManager *n = new QNetworkAccessManager();
  4. QString contentType = "";
  5.  
  6. QNetworkRequest req(request.url());
  7.  
  8. const QList<QByteArray>a = request.rawHeaderList();
  9. int i = 0; int j = a.length();
  10. for(;i<j;i++){
  11. qDebug() << a[i] << ": " << request.rawHeader(a[i]);
  12. req.setRawHeader(a[i],request.rawHeader(a[i]));
  13. }
  14.  
  15. if(contentType!=""){
  16. req.setHeader(QNetworkRequest::ContentTypeHeader, contentType);
  17. }
  18.  
  19. const QByteArray data = outgoingData->readAll();
  20. QNetworkReply *p = n->post(req,data);
  21.  
  22. //wait request finish
  23. QEventLoop loop;
  24. connect(p, SIGNAL(finished()), &loop, SLOT(quit()));
  25. loop.exec();
  26.  
  27. if(/*the attempt limit*/){
  28. if(p->errorString()=="Unknown error") {
  29. //tries to resend again when the error occurs "Unknown Error"
  30. return myNAM::createRequest(op, request, outgoingData);
  31. }
  32. //sends request ready.
  33. return QNetworkAccessManager::createRequest(op, p->request(), outgoingData);
  34. }
  35. }
  36.  
  37. //send normal mode, GET, PUT and DELETE or chance the retry limit has finished
  38. return QNetworkAccessManager::createRequest(op, request, outgoingData);
  39. }
To copy to clipboard, switch view to plain text mode 

The code worked perfectly, did not need the number of attempts, only to recreate the request stopped the error occurs, occurs randomly but I added a "IF" with the limited number of attempts.

But still would like to know if you have any tips to further improve my code?