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. QTimer singleShot resolution

QTimer singleShot resolution

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 925 Views 1 Watching
  • 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.
  • S Offline
    S Offline
    sting
    wrote on last edited by
    #1

    I am building a networked event controled application. The events are very simple:

    Client sents a request to a server;
    Server gets the request and sends a response back to the client.

    It works well, but probably not perfect. The problem is I want to use QTimer single shot events to know if I don't get a response back within a specific time, it is pretty big, so the client knows when it should go into the devcon 3 state :).

    In the class constructor I have:
    @
    cmdTimer = new QTimer();
    cmdTimer->setSingleShot(true);
    connect(cmdTimer, SIGNAL(timeout()), this, SLOT(timeout()));
    connect(this, SIGNAL(stopTimer(int)), cmdTimer, SLOT(stop()));
    @

    I start the singleShot timer as follows:
    @
    // just before the request
    cmdTimer->singleShot(100, this, SLOT(timeout()));
    sendRequest();
    @

    I stop the timer if the event comes in as follows:
    @
    emit stopTimer();
    @

    If the response comes back before the timeout is fired all is good, the timer is stoped and I never get the timeout. I am trying to ensure it works correctly so I have the server sleep for a period twice as long as the singleshot request and I expect to get a timeout with each request.

    I get the first couple of timeouts correctly, but after a few they stop for 4 commands and after the 4th command I get the 4 outstanding timeouts. Also, could this be because I am still debugging the app on a single machine?

    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