July 2, 2011

Max13 Max13
Ant Farmer
67 posts

[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

4 replies

July 3, 2011

renato.filho renato.filho
Lab Rat
54 posts

You need call this qApp->processEvents() inside of your encrypt function (loops), or call this encrypt function in a different thread (check QThread).

July 3, 2011

Max13 Max13
Ant Farmer
67 posts

Yup.
Thank you, i’ve tryied to do the encryption processes in a different threads. My only regrets is that I had to changed my app stucture a little.

Anyway, thank you, thank QThread.

July 3, 2011

renato.filho renato.filho
Lab Rat
54 posts

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.

July 3, 2011

Max13 Max13
Ant Farmer
67 posts

No problems ;)

I’ve only put the decrypt() and encrypt() in a different thread ;)
And i’ve connected “start” with “show”, and “finished” with “close” :D

Thank you anyway !

 
  ‹‹ problem in running the exe file      Help with what should i include for translation at my app. ››

You must log in to post a reply. Not a member yet? Register here!