PDA

View Full Version : How to execute a time-consuming task without UI pause?



weixj2003ld
24th May 2020, 00:42
I create a button,and use
connect(button, SIGNAL(clicked()),this, SLOT(process() )) ,
In process(),there is a loop,for example,1...1000000.
when I click the button,the UI pause.

How to deal with it? thank you.

ChrisW67
24th May 2020, 06:08
That depends on what the processing is and what level of control you have over it.

For a fair sized discussion of this topic see Keeping the GUI Responsive (https://doc.qt.io/archives/qq/qq27-responsive-guis.html). That was written a few years ago before Qt5 but all the same considerations apply.

d_stranz
24th May 2020, 16:47
Keeping the GUI Responsive.

I hope the folks at Qt realize the value of Wysota's article and continue to keep it available in the archives. As do you, whenever I see a post like the above my first thought is, refer them to this article. I have a PDF version, so I guess if the archive post goes away, I can upload that when needed.

weixj2003ld
27th May 2020, 04:22
Thank you very much.I'll read this article.