我正在为我的C++类做一个项目,我们正在做一个扑克程序与人工智能和用户。在开发中使用QT。
我需要做的是在函数决定()中,如果玩家不是AI,程序就会暂停,直到用户点击按钮来折叠、调用或提升。
基本上,我需要在执行函数的过程中暂停一个程序,直到用户按下一个按钮。然后,它将继续该函数的其余部分。
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);
}发布于 2019-04-10 06:32:05
可以使用QEventLoop等待用户输入,例如,单击按钮将退出事件循环。
//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();https://stackoverflow.com/questions/55605925
复制相似问题