What can I do if I want to blocked waiting for QModbusReply
-
I am using QModbusClient object as a modbus tcp master. I refered the example ,but it implement by async mode(connect to finished signals). But now ,because of some reason ,I want to wait the reply blocked.I tryied call "isFinished" API like :
while(reply->isFinished()){
//wait
}
, but it always retured false,I don‘t know why,Any suggestion?
THANKS!! -
I modify the code as your suggestion,it works well,thanks a lot
-
I am using QModbusClient object as a modbus tcp master. I refered the example ,but it implement by async mode(connect to finished signals). But now ,because of some reason ,I want to wait the reply blocked.I tryied call "isFinished" API like :
while(reply->isFinished()){
//wait
}
, but it always retured false,I don‘t know why,Any suggestion?
THANKS!!@coderKnight Use a local event loop (https://doc.qt.io/qt-6/qeventloop.html). Connect the finished sginal from the reply with https://doc.qt.io/qt-6/qeventloop.html#exit then start the request and the local event loop (https://doc.qt.io/qt-6/qeventloop.html#exec>)
-
I modify the code as your suggestion,it works well,thanks a lot