Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
725 views
in Technique[技术] by (71.8m points)

user interface - Should I use QCoreApplication::processEvents() or QApplication::processEvents()?

I have a method which is called from both QThreads and the main thread. this method can sometimes take a long time to do its computations in a loop so I put QCoreApplication::processEvents() and this prevents the GUI from freezing. At some point I had changed QCoreApplication::processEvents() for QApplication::processEvents() but that caused the GUI to freeze (im pretty sure thats what was fereezing it because since I put QCoreApplication::processEvents() back it hasnt frozen again) Am I right to think that calling QApplication::processEvents() from both the main thread and QThreads can freeze the GUI?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Neither, processEvent() should be calld only when you have actual pending events to process. You may find this useful : How to make Qt work when main thread is busy?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...