I am working on a project for my C++ Class and we are doing a poker program with AI and users. Using QT for the development.
What I need to do is inside of the function DECISION() if the player is not an AI, the program pauses until the user hits buttons to either fold, call, or Raise.
Basically I need to pause a program in the middle of executing a function, until the user presses a button. Then it will continue the rest of the function
if(Player[pp].ai == true){
//A bunch of code for AI decision making for folding, calling, raising.
}
else{ //If Player is NOT an AI
ENABLEUSERINPUT(true);
//Need to pause program here until the user has done something to the GUI
ENABLESERINPUT(false);
}
It's possible to wait for a user input using the QEventLoop
for example clicking on the button will exit the event loop.
//Need to pause program here until the user has done something to the GUI
QEventLoop oLoop;
// user click on button will release the event loop.
connect(pYoutrBtn , &QPushButton::clicked,
&oLoop, &QEventLoop::quit);
// wait.
oLoop.exec();