PDA

View Full Version : Re: Progress Bar On status Bar Help (Solved)



ShapeShiftme
20th May 2011, 07:48
Good Day All.

Im trying to add a progress bar to my status bar for my webview

i emit signals on loadfinished and load started which call the following functions

to create the progress bar :


//Insert progress bar on status bar
QProgressBar *progressBar = new QProgressBar(NULL);
progressBar->setMaximumHeight(16);
progressBar->setMaximumWidth(200);
progressBar->setTextVisible(false);
this->statusBar()->addWidget(progressBar, 0);
this->statusBar()->showMessage(QString("Loading"));

progressBar->setValue(0);
progressBar->setMinimum(0);
progressBar->setMaximum(0);


Now When i view webpages i keep getting more prograssbars added so im gathering i need to remove the progress bar. but i dont know how to do that


this->statusBar()->clearMessage();
this->statusBar()->removeWidget();

This functions are run on the mainform as i have a mdiarea. so the signal is passed to the main form from the subwindow onloadstart and load finished event.

Any help would be greatly appreciated

Added after 37 minutes:

Ok my bad. figured it out. i had to declare the progress bar in the header file
like so

mainwindow.h


private:
Ui::MainWindow *ui;
QProgressBar *progressBar;

Then i had to change the above slots to :


progressBar = new QProgressBar;
progressBar->setMaximumHeight(16);
progressBar->setMaximumWidth(200);
progressBar->setTextVisible(false);
this->statusBar()->addPermanentWidget(progressBar, 0);
this->statusBar()->showMessage(QString("Loading"));

//((QMainWindow*)parent())->statusBar()->addPermanentWidget(progressBar, 0);
//((QMainWindow*)parent())->statusBar()->showMessage(QString("Loading"));
progressBar->setValue(0);
progressBar->setMinimum(0);
progressBar->setMaximum(0);


And

this->statusBar()->clearMessage();
this->statusBar()->removeWidget(progressBar);