Should I use QCoreApplication::processEvents() or QApplication::processEvents()?

前端 未结 2 1465
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 12:47

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

2条回答
  •  遥遥无期
    2020-11-30 13:23

    You'll be much better off moving the long-running process out of the main thread so you don't need to call processEvents(). Within that long-running process, you can emit whatever signals you need so the gui has sufficient information to do updates, etc. processEvents, however, is usually a crutch for a poor design.

提交回复
热议问题