I have this code like this:

Qt Code:
  1. bool XmlSpoListParser::read()
  2. {
  3. while (!atEnd()) {
  4. readNext();
  5.  
  6. if (isStartElement()) {
  7. if (name() == QLatin1String("Tag") && attributes().value(QLatin1String("version")) == QLatin1String("1.0")) {
  8. readSomething1();
  9. break;
  10. } else {
  11. raiseError(QObject::tr("The file is not an Tag version 1.0 file."));
  12. break;
  13. }
  14. }
  15. if (hasError() && onError()) {
  16. break;
  17. }
  18. }
  19.  
  20. return !error();
  21. }
  22.  
  23. bool XmlSpoListParser::onError()
  24. {
  25. if (error() == QXmlStreamReader::PrematureEndOfDocumentError) {
  26. appendMoreData();
  27. return false;
  28. } else {
  29. qDebug() << errorString();
  30. return true;
  31. }
  32. }
  33.  
  34. void XmlSpoListParser::appendMoreData()
  35. {
  36. //???
  37. }
  38.  
  39. void XmlSpoListParser::readSomething1()
  40. {
  41. while (!(isEndElement() && name() == QLatin1String("Tag2")) && !atEnd()) {
  42. readNext();
  43. if (isStartElement()) {
  44. if (name() == QLatin1String("Tag3")) {
  45. readSomething2();
  46. } else {
  47. skipSubTree();
  48. }
  49. }
  50. if (hasError() && onError()) {
  51. break;
  52. }
  53. }
  54. }
  55.  
  56. void XmlSpoListParser::readSomething2()
  57. {
  58. while (!(isEndElement() && name() == QLatin1String("Tag3")) && !atEnd()) {
  59. readNext();
  60. if (isStartElement()) {
  61. if (name() == QLatin1String("Tag4")) {
  62. readSomething3();
  63. } else {
  64. skipSubTree();
  65. }
  66. }
  67. if (hasError() && onError()) {
  68. break;
  69. }
  70. }
  71. }
To copy to clipboard, switch view to plain text mode 

How i can wait data from socket when error PrematureEndOfDocumentError occured from readSomething2() method (for example)? I wan't call addData() to parser and return back to method readSomething1() after new data arrived. What i must do, create additional QEventLoop in method appendMoreData, or use infinite while(1) with QApplication::processEvents() or what?