consider the following:

Qt Code:
  1. void FuelSystem::DSLFL_DataReceive(QByteArray data)
  2. {
  3. /* 4)Lower sensor 5)upper Sensor 6)water sensor */
  4.  
  5. QByteArray command_SV15;
  6. QByteArray command_HV14;
  7. QByteArray command_FTWL_SV9;
  8.  
  9. if(data.at(3) == FUEL_SYSTEM)
  10. {
  11. if(data.at(4) == 0x01)
  12. {
  13. FuelPump_start();
  14.  
  15. command_SV15.append(FUEL_SYSTEM);
  16. command_SV15.append(DSLFL_ST_SV_15);
  17. command_SV15.append(0x01);
  18.  
  19. emit DSLFL_SendToRS485(command_SV15);
  20. delay(_DELAY_MSEC);
  21. }
  22. else if(data.at(5) == 0x01)
  23. {
  24. FuelPump_stop();
  25.  
  26. command_HV14.append(FUEL_SYSTEM);
  27. command_HV14.append(DSLFL_HT_SV_14);
  28. command_HV14.append((char) 0x00);
  29.  
  30. emit DSLFL_SendToRS485(command_HV14);
  31. delay(_DELAY_MSEC);
  32. }
  33.  
  34. if((data.at(6) == 0x01) && (pumpStat == OFF))
  35. {
  36. command_FTWL_SV9.append(FUEL_SYSTEM);
  37. command_FTWL_SV9.append(DSLFLWaterEvacuate_SV_9);
  38. command_FTWL_SV9.append(0x01);
  39.  
  40. emit DSLFL_SendToRS485(command_FTWL_SV9);
  41. delay(_DELAY_MSEC);
  42.  
  43. waterEvacuateTimer->start();
  44. }
  45. }
  46. }
  47.  
  48. void FuelSystem::delay(int msec){
  49. QEventLoop loop;
  50. QTimer::singleShot(msec, &loop, NULL);
  51. loop.exec();
  52. }
To copy to clipboard, switch view to plain text mode 

As I send a packet to PLC, I need to delay for some time, waiting for the result of PLC operations. Here, I cannot use sleep() as it is a system call and it will suspend all other
QTimers and the whole program. what I want is to only delay the current particular thread or object for 2 seconds everytime I connect to PLC.

I hope this is clear now. : )