QProgressBar not showing progress?

后端 未结 3 622
耶瑟儿~
耶瑟儿~ 2020-12-01 22:07

My first naive at updating my progress bar was to include the following lines in my loop which is doing the processing, making something like this:

while(dat         


        
3条回答
  •  一整个雨季
    2020-12-01 22:27

    You need to call QApplication::processEvents() periodically inside your processing loop to let it handle UI events.

    As Georg says, Qt is a single-threaded co-operative multitasking environment. You get full control of your process until you relinquish it voluntarily with processEvents() - until you do that, Qt can't update the UI elements, handle async HTTP requests, handle input, or pretty much anything else. It's up to you to make sure that stuff gets a timeslice while you're in a long processing loop.

提交回复
热议问题