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. QDialog bug?
Qt 6.11 is out! See what's new in the release blog

QDialog bug?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 868 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
    MScottM
    wrote on last edited by
    #1

    Okay, I have a QDialog that I call just before a while statement:

    QProgressDialog progress("Loading Log Data...","Cancel", 0, 0, this);
        progress.setWindowModality(Qt::NonModal);
        progress.show();
    

    When I say 'progress.show()' the dialog pops up as a blank dialog box, but it will act as expected, going away when the while statement completes.

    0_1531832045169_896284bd-fae0-4e74-8f49-7692cf75f45c-image.png

    But when I say 'progress.exec() it shows the 'busy' bar as I want (because it's unknown how large the data set is that the while statement is working on), but it never allows the while statement to start until I cancel the dialog - then the dialog goes away and then the 'while' statement starts and completes.

    0_1531832699365_f1d6ad41-f8c7-495f-944a-df52eeba1598-image.png

    Is this a bug or my bad coding?

    -Scott

    raven-worxR 1 Reply Last reply
    0
    • M MScottM

      Okay, I have a QDialog that I call just before a while statement:

      QProgressDialog progress("Loading Log Data...","Cancel", 0, 0, this);
          progress.setWindowModality(Qt::NonModal);
          progress.show();
      

      When I say 'progress.show()' the dialog pops up as a blank dialog box, but it will act as expected, going away when the while statement completes.

      0_1531832045169_896284bd-fae0-4e74-8f49-7692cf75f45c-image.png

      But when I say 'progress.exec() it shows the 'busy' bar as I want (because it's unknown how large the data set is that the while statement is working on), but it never allows the while statement to start until I cancel the dialog - then the dialog goes away and then the 'while' statement starts and completes.

      0_1531832699365_f1d6ad41-f8c7-495f-944a-df52eeba1598-image.png

      Is this a bug or my bad coding?

      -Scott

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @MScottM said in QDialog bug?:

      Is this a bug or my bad coding?

      rather bad coding.
      If you do your heavy work (while-loop) in the gui thread nothing can update the display obviously.
      So you should move your while loop into another thread and report the progress to the dialog via signals.

      Alternatively (which i actually never recommend) you can call QCoreApplication::processEvents() in the while loop to let the gui thread do it's work intermediately.

      btw. QDialog::exec() creates it's own event-loop and blocks until the dialog is closed.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      4
      • M Offline
        M Offline
        MScottM
        wrote on last edited by
        #3

        @raven-worx - thanks for your reply. It makes sense - I'll make understanding worker threads my next project.

        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