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. Custom QProgressDialog
QtWS25 Last Chance

Custom QProgressDialog

Scheduled Pinned Locked Moved Solved General and Desktop
qprogressdialogqprogressbar
3 Posts 2 Posters 1.6k Views
  • 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.
  • S Offline
    S Offline
    shahriar25
    wrote on last edited by shahriar25
    #1

    Hi
    I wanted to build a custom progress dialog for my project so I built a dialog with a progressBar in the ui and two public functions:
    void setProgressBarValue(int value)
    {
    ui->progressBar->setValue(value);
    }

    void setProgressBarRange(int min, int max)
    {
    ui->progressBar->setRange(min, max);
    }

    And in my project:

    myProgressDialog *dialog = new myProgressDialog;
    dialog.setProgressBarRange(0,100);
    dialog.show();

    for (int i=0; i<=100; ++i)
    {
    dialog.setProgressBarValue(i);
    }

    And when I run it it shows the dialog but inside the dialog is black until it reaches 100
    I know I'm doing everything wrong so can someone tell me how to do it?

    1 Reply Last reply
    0
    • kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      Hello,
      Your code doesn't allow for the events to be processed between the calls to dialog.setProgressBarValue(i);, this is why the first paint event you'll get processed is after the loop finishes. You could manually request events to be processed in the loop by using QCoreApplication::processEvents.

      Kind regards.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        shahriar25
        wrote on last edited by
        #3

        Hi,
        Thank you so much. I did it.

        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