Is it possible to call QApplication::processEvents() inside the event han开发者_运维问答dler, where there is a long process. My program terminates with Segfault. My code is something like this:
void MyApplication::customEvent(QEvent* event)
{
if(event->type() == UserEventCustom)
{
for(int i = 0; i < 99999; ++i)
{
QApplication::processEvents();
doSomething();
}
event->accept();
}
}
I suspect that Ton van den Heuvel (from comments) is correct that you are seeing a stack overflow.
However, at my company, we have found it best to avoid processEvents(). Our experience has shown processEvents() to cause crashes and we try to avoid its use. I would ask yourself whether you could refactor your code to do without the processEvents() call. For example, you might spawn a thread to do you processing.
精彩评论