Hi!

Like in the subject.
I was try two function request and is it possible to clear reply data somewhere in Qt code?
Because when I set test_value to ONLY_NETWORK_REQUEST i get some data in function parseReplay in line 28. But when I load page in webView, function parseReplay is executed, and in line 28 I take emty QByteArray.
Why?

Qt Code:
  1. MainWindow::MainWindow(QWidget *parent) :
  2. QMainWindow(parent),
  3. ui(new Ui::MainWindow)
  4. {
  5. ui->setupUi(this);
  6.  
  7. nam = new NetworkAccessManager();
  8. ui->webView->page()->setNetworkAccessManager(nam);
  9.  
  10. connect(
  11. nam, SIGNAL(finished(QNetworkReply*)),
  12. this, SLOT(parseReply(QNetworkReply*))
  13. );
  14. }
  15.  
  16. MainWindow::~MainWindow()
  17. {
  18. delete ui;
  19. }
  20.  
  21. void MainWindow::parseReply(QNetworkReply * r)
  22. {
  23. if( r->isOpen() and r->isFinished() )
  24. {
  25. r->waitForReadyRead(1000);
  26. if( r->reset() )
  27. {
  28. qDebug() << "data: " << r->readAll().size() << r->isReadable();
  29. }
  30. }
  31. }
  32.  
  33. void MainWindow::on_goButton_clicked()
  34. {
  35. QString url = ui->urlLineEdit->text();
  36. if( ! url.startsWith("http://") )
  37. url.prepend("http://");
  38.  
  39. switch( test_value )
  40. {
  41. case ONLY_NETWORK_REQUEST:
  42. nam->get(QNetworkRequest(url));
  43. break;
  44.  
  45. case NETWORK_REQUEST_WITH_WEB_VIEW:
  46. ui->webView->load( url );
  47. break;
  48. }
  49. }
To copy to clipboard, switch view to plain text mode