QThread execution freezes my GUI

前端 未结 3 1691
别跟我提以往
别跟我提以往 2021-01-03 10:21

I\'m new to multithread programming. I wrote this simple multi thread program with Qt. But when I run this program it freezes my GUI and when I click inside my widow, it res

3条回答
  •  没有蜡笔的小新
    2021-01-03 10:36

    But when I run this program it freezes my GUI and when I click inside my window, it responds that your program is not responding.

    Yes because IMO you're doing too much work in thread that it exhausts CPU. Generally program is not responding message pops up when process show no progress in handling application event queue requests. In your case this happens.

    So in this case you should find a way to divide the work. Just for the sake of example say, thread runs in chunks of 100 and repeat the thread till it completes 10000000.

    Also you should have look at QCoreApplication::processEvents() when you're performing a lengthy operation.

提交回复
热议问题