[Solved] Showing "Loading" widget while heavy processing...
-
Hi,
I'm new to Qt, and i'm on a cryptographic app.I'm using drag-and-drop features in my app, and when you drop a clear file, i call a method "encrypt(filename)", which block the entire app during the encryption.
I want to show the user i'm processing his file, so I'm creating a QWidget with the SplashScreen flag, but when I do "loadingWidget->show()" THEN "encrypt()", there is a white and empty widget showing, then the app is blocked while the file is being encrypted, THEN the widget show the text "Loading".I tryied:
loadingWidget->show();
qApp->processEvents();
loadingWidget->update();Nothing works. Any idea :/ ?
(I don't even know the problem :( )Thank you for your help !
PS: Here is my drop function: http://pastebin.com/XeJZwRXq -
You need call this qApp->processEvents() inside of your encrypt function (loops), or call this encrypt function in a different thread (check QThread).
-
Be careful with threads and UI objects. Remember that: you can not make changes on the ui direct from a different thread, use signals and slots or post events on application main loop.