Results 1 to 5 of 5

Thread: How to wait for one of three buttons to be clicked in loop?

  1. #1
    Join Date
    May 2014
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default How to wait for one of three buttons to be clicked in loop?

    Hi!
    I'm writing simple poker game and I stopped at problem - i've got a loop in which enemies are making their decisions but I don't know how to make application wait for player click on one of buttons when becomes his turn and continue after click. How should I do it?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to wait for one of three buttons to be clicked in loop?

    "Waiting in a loop" does not work very well with event driven systems.

    You could just disable the buttons until it is the user's turn, or, in the slot connected to the buttons, check if it is the user's turn and ignore the slot invocation if it is not.

    Cheers,
    _

  3. #3
    Join Date
    May 2014
    Posts
    3
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to wait for one of three buttons to be clicked in loop?

    How should i check if one of buttons was clicked to continue? Should I add something to signal&slot connection?

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to wait for one of three buttons to be clicked in loop?

    I think that QStateMachine is good solution for You.

  5. #5
    Join Date
    Jun 2014
    Posts
    7
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to wait for one of three buttons to be clicked in loop?

    You might also want to re-think your logic.
    After the decision-making step, you'd want to enable the buttons.
    After clicking on them, disable them.
    You connect each button to a signal, and each of those to a small function where you would launch the next step.

Similar Threads

  1. For loop and While loop handling.
    By kiboi in forum Newbie
    Replies: 7
    Last Post: 2nd January 2013, 14:43
  2. Wait Condition Indication to User Using Loading/Wait Message
    By vivek.panchal in forum Qt Programming
    Replies: 4
    Last Post: 14th August 2012, 17:40
  3. Replies: 4
    Last Post: 6th August 2011, 02:40
  4. Main loop thread loop communication
    By mcsahin in forum Qt Programming
    Replies: 7
    Last Post: 25th January 2011, 17:31
  5. Replies: 7
    Last Post: 20th November 2007, 13:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.