我有以下代码:
paintGL()
{
if(mouse_was_clicked)
{
... do the color picking with openGL to identify a clicked element
... !!! now I need to call again paintGL() to switch the selected element from the
old one to the new one but I can't create a recursive cycle!
}
else
{
... normal code to draw the scene and the selected element in red ...
}
}
如行所示,我需要一种方法来再次调用绘制事件。有没有什么方法可以在不创建潜在活锁的情况下完成此操作?比如推迟新的油漆事件?
最佳答案
如果您的 paintGL()
中的控制流如此简单,只需确保当前在 else
block 中的内容在每种情况下都被执行:
void MyWidget::paintGL()
{
if(mouse_was_clicked)
{
... do the color picking with openGL to identify a clicked element
}
... normal code to draw the scene and the selected element in red ...
}
关于c++ - Qt - 需要递归重绘,怎么样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11595977/