Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Showing "Loading" widget while heavy processing...
Qt 6.11 is out! See what's new in the release blog

[Solved] Showing "Loading" widget while heavy processing...

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 5.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Max13
    wrote on last edited by
    #1

    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

    We all have started by asking questions. Then after some time, we can begin answering them.

    1 Reply Last reply
    0
    • R Offline
      R Offline
      renato.filho
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Max13
        wrote on last edited by
        #3

        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.

        We all have started by asking questions. Then after some time, we can begin answering them.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          renato.filho
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Max13
            wrote on last edited by
            #5

            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 !

            We all have started by asking questions. Then after some time, we can begin answering them.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved