I use a Qcoreapplication in the main function of a program. I have a sequence of communicating nodes which is read from a file (line by line). At each line, I call sendHello(src,dst). A simple description of the code is as follows:

file format:
node1 node2
node3 node4
node5 node6

Qt Code:
  1. int main()
  2. {
  3. Qcoreapplication app;
  4. readfromfile();
  5. app.exec()
  6. }
  7. readfromfile()
  8. {
  9. while(!eof())
  10. sendhello(src,dst),
  11. }
  12. sendHello(src,dst)
  13. {
  14. // Here exchange different messages (more events)
  15. sendmsg2(dst,src)
  16. sendmsg3(src,dst)
  17. }
To copy to clipboard, switch view to plain text mode 

Calling each of this sendHello() by each pair, initiates different exchange of information (different events). I found out that the main loop goes from line to line (from pair to pair) and performs the sendHello for each pair sequentially.

Results I get:

sendHello(node1,node2)
sendHello(node3,node4)
sendmsg2(node2,node1)
sendmsg3(node1,node2)
sendmsg2(node4,node3)
sendmsg3(node2,node4)

I need to execute the events that are contained in each sendHello (sendmsg2 and sendmsg3) before moving to next lines (pairs). I tried to understand how to control the events of the main event loop, and how the middle events are scheduled but I did not.

Results I need:

sendHello(node1,node2)
sendmsg2(node2,node1)
sendmsg3(node1,node2)

sendHello(node3,node4)
sendmsg2(node4,node3)
sendmsg3(node2,node4)

I tried processevents( all events) but it`s not working as required. Don`t know why ?

Thanks in advance