PDA

View Full Version : How to wait for one of three buttons to be clicked in loop?



adatter
31st May 2014, 16:02
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?

anda_skoa
31st May 2014, 16:56
"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,
_

adatter
2nd June 2014, 20:04
How should i check if one of buttons was clicked to continue? Should I add something to signal&slot connection?

Lesiok
3rd June 2014, 06:46
I think that QStateMachine is good solution for You.

QNewbie
5th June 2014, 21:34
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.