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. Empty space shown next to progress bar in QProgressDialog

Empty space shown next to progress bar in QProgressDialog

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.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.
  • ScleaverZer0neS Offline
    ScleaverZer0neS Offline
    ScleaverZer0ne
    wrote on last edited by ScleaverZer0ne
    #1

    I have a QProgressDialog in my application. I have hidden the text of the progress bar in that dialog, but there's an empty space on the right side of that progress bar.

    This is what I did:

    QLabel *label = new QLabel("Sync with entities started by user: " + szUser + ". Please wait...");
    
    label->setStyleSheet("color:rgb(255,255,255);"
                         "font-size: 15px;"
                         "border: 1px solid rgb(72,72,72)");
    
    progressDialogSync.setStyleSheet("QProgressDialog {"
                                     "    background-color:rgb(72,72,72);"
                                     "    padding: 20px;"
                                     "    border: 3px solid rgb(50,50,50);"
                                     "    border-radius: 5px;"
                                     "}"
                                     "QProgressBar {"
                                     "    border: 2px solid white;"
                                     "    padding: 1px;"
                                     "}");
    
    progressDialogSync.setCancelButton(nullptr);
    progressDialogSync.setLabel(label);
    progressDialogSync.setMinimum(0);
    progressDialogSync.setMaximum(0);
    progressDialogSync.setAutoClose(true);
    progressDialogSync.resize(progressDialogSync.width(), 100);
    progressDialogSync.setWindowFlags(Qt::FramelessWindowHint);
    progressDialogSync.setWindowModality(Qt::ApplicationModal);
    
    QProgressBar *bar = progressDialogSync.findChild<QProgressBar *>();
    bar != nullptr ? bar->setTextVisible(false) : void();
    
    while(bSyncInProgress) {
        progressDialogSync.exec();
    }
    

    And this is how it looks:

    bc385e27-de09-4b2e-9e23-319e5ec68870-image.png

    How do I get rid of that empty space so that my progress bar is either centered or takes up the width of the dialog box.

    ScleaverZer0neS 1 Reply Last reply
    0
    • ScleaverZer0neS ScleaverZer0ne

      @JoeCFD I'm on Windows 10 using Qt 5.13

      ScleaverZer0neS Offline
      ScleaverZer0neS Offline
      ScleaverZer0ne
      wrote on last edited by
      #5

      I created a clean project and used the same code, and there was no empty space on the right. Then I checked if my project had a stylesheet set for the QProgressBar in general in the ".qss" file. Turns out someone before me had set there a margin on the right side of the progress bar. Removing that resolved my problem. Only if I checked that a little sooner.

      1 Reply Last reply
      0
      • ScleaverZer0neS ScleaverZer0ne

        I have a QProgressDialog in my application. I have hidden the text of the progress bar in that dialog, but there's an empty space on the right side of that progress bar.

        This is what I did:

        QLabel *label = new QLabel("Sync with entities started by user: " + szUser + ". Please wait...");
        
        label->setStyleSheet("color:rgb(255,255,255);"
                             "font-size: 15px;"
                             "border: 1px solid rgb(72,72,72)");
        
        progressDialogSync.setStyleSheet("QProgressDialog {"
                                         "    background-color:rgb(72,72,72);"
                                         "    padding: 20px;"
                                         "    border: 3px solid rgb(50,50,50);"
                                         "    border-radius: 5px;"
                                         "}"
                                         "QProgressBar {"
                                         "    border: 2px solid white;"
                                         "    padding: 1px;"
                                         "}");
        
        progressDialogSync.setCancelButton(nullptr);
        progressDialogSync.setLabel(label);
        progressDialogSync.setMinimum(0);
        progressDialogSync.setMaximum(0);
        progressDialogSync.setAutoClose(true);
        progressDialogSync.resize(progressDialogSync.width(), 100);
        progressDialogSync.setWindowFlags(Qt::FramelessWindowHint);
        progressDialogSync.setWindowModality(Qt::ApplicationModal);
        
        QProgressBar *bar = progressDialogSync.findChild<QProgressBar *>();
        bar != nullptr ? bar->setTextVisible(false) : void();
        
        while(bSyncInProgress) {
            progressDialogSync.exec();
        }
        

        And this is how it looks:

        bc385e27-de09-4b2e-9e23-319e5ec68870-image.png

        How do I get rid of that empty space so that my progress bar is either centered or takes up the width of the dialog box.

        ScleaverZer0neS Offline
        ScleaverZer0neS Offline
        ScleaverZer0ne
        wrote on last edited by
        #2

        Would love some input on this

        JoeCFDJ 1 Reply Last reply
        0
        • ScleaverZer0neS ScleaverZer0ne

          Would love some input on this

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #3

          @ScleaverZer0ne what is your Qt version? And OS?

          ScleaverZer0neS 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            @ScleaverZer0ne what is your Qt version? And OS?

            ScleaverZer0neS Offline
            ScleaverZer0neS Offline
            ScleaverZer0ne
            wrote on last edited by
            #4

            @JoeCFD I'm on Windows 10 using Qt 5.13

            ScleaverZer0neS 1 Reply Last reply
            0
            • ScleaverZer0neS ScleaverZer0ne

              @JoeCFD I'm on Windows 10 using Qt 5.13

              ScleaverZer0neS Offline
              ScleaverZer0neS Offline
              ScleaverZer0ne
              wrote on last edited by
              #5

              I created a clean project and used the same code, and there was no empty space on the right. Then I checked if my project had a stylesheet set for the QProgressBar in general in the ".qss" file. Turns out someone before me had set there a margin on the right side of the progress bar. Removing that resolved my problem. Only if I checked that a little sooner.

              1 Reply Last reply
              0
              • ScleaverZer0neS ScleaverZer0ne has marked this topic as solved on

              • Login

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