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
Forum Update on Monday, May 27th 2025

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 4 Jan 2016, 18:28 last edited by shahriar25 1 Apr 2016, 18:29
    #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
    • K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 4 Jan 2016, 18:35 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 5 Jan 2016, 10:55 last edited by
        #3

        Hi,
        Thank you so much. I did it.

        1 Reply Last reply
        0

        1/3

        4 Jan 2016, 18:28

        • Login

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