Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What can I do if I want to blocked waiting for QModbusReply
Forum Updated to NodeBB v4.3 + New Features

What can I do if I want to blocked waiting for QModbusReply

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 412 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    coderKnight
    wrote on last edited by
    #1

    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!!

    jsulmJ 1 Reply Last reply
    0
    • C Offline
      C Offline
      coderKnight
      wrote on last edited by
      #3

      I modify the code as your suggestion,it works well,thanks a lot

      1 Reply Last reply
      0
      • C coderKnight

        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!!

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @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>)

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • C Offline
          C Offline
          coderKnight
          wrote on last edited by
          #3

          I modify the code as your suggestion,it works well,thanks a lot

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved