Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[SOLVED]How to set the position of progress bar at right corner of statusbar



  • @progressBar=new QProgressBar(ui->statusBar);
    progressBar->setMaximumSize(170,19);
    // position of progress bar should be extreme right
    ui->statusBar->addWidget(progressBar); @



  • I don't know your specific use case but you could use "a permanent widget":http://qt-project.org/doc/qt-4.8/qstatusbar.html#addPermanentWidget
    Which is situated at the right.



  • Thanks a lot! It did the job.



  • [quote author="adnan" date="1345363580"]@progressBar=new QProgressBar(ui->statusBar);
    progressBar->setMaximumSize(170,19);
    // position of progress bar should be extreme right
    ui->statusBar->addWidget(progressBar);@ [/quote]

    For some reason mine is at the extreme left:

    @
    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    progressBar = new QProgressBar(ui->statusBar);
    progressBar->setAlignment(Qt::AlignRight);
    progressBar->setMaximumSize(180, 19);
    ui->statusBar->addWidget(progressBar);
    progressBar->setValue(50);
    }

    @

    I Guess addPermanentWidget is the ticket.



  • Instead of using
    @ ui->statusBar->addWidget(progressBar);@

    Use
    @ ui->statusBar->addPermanentWidget(progressBar);@


Log in to reply