[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).



  • 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.



  • 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.



  • 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 !


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.