Results 1 to 1 of 1

Thread: Re: Progress Bar On status Bar Help (Solved)

  1. #1
    Join Date
    Dec 2010
    Location
    South Africa
    Posts
    56
    Thanks
    8
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Progress Bar On status Bar Help (Solved)

    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 :

    Qt Code:
    1. //Insert progress bar on status bar
    2. QProgressBar *progressBar = new QProgressBar(NULL);
    3. progressBar->setMaximumHeight(16);
    4. progressBar->setMaximumWidth(200);
    5. progressBar->setTextVisible(false);
    6. this->statusBar()->addWidget(progressBar, 0);
    7. this->statusBar()->showMessage(QString("Loading"));
    8.  
    9. progressBar->setValue(0);
    10. progressBar->setMinimum(0);
    11. progressBar->setMaximum(0);
    To copy to clipboard, switch view to plain text mode 


    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

    Qt Code:
    1. this->statusBar()->clearMessage();
    2. this->statusBar()->removeWidget();
    To copy to clipboard, switch view to plain text mode 

    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

    Qt Code:
    1. private:
    2. Ui::MainWindow *ui;
    3. QProgressBar *progressBar;
    To copy to clipboard, switch view to plain text mode 

    Then i had to change the above slots to :

    Qt Code:
    1. progressBar = new QProgressBar;
    2. progressBar->setMaximumHeight(16);
    3. progressBar->setMaximumWidth(200);
    4. progressBar->setTextVisible(false);
    5. this->statusBar()->addPermanentWidget(progressBar, 0);
    6. this->statusBar()->showMessage(QString("Loading"));
    7.  
    8. //((QMainWindow*)parent())->statusBar()->addPermanentWidget(progressBar, 0);
    9. //((QMainWindow*)parent())->statusBar()->showMessage(QString("Loading"));
    10. progressBar->setValue(0);
    11. progressBar->setMinimum(0);
    12. progressBar->setMaximum(0);
    To copy to clipboard, switch view to plain text mode 

    And
    Qt Code:
    1. this->statusBar()->clearMessage();
    2. this->statusBar()->removeWidget(progressBar);
    To copy to clipboard, switch view to plain text mode 
    Last edited by ShapeShiftme; 20th May 2011 at 06:48.

Similar Threads

  1. How to display progress bar?
    By qutron in forum Newbie
    Replies: 3
    Last Post: 17th May 2011, 16:10
  2. How to use progress bar
    By Ashwani in forum Newbie
    Replies: 6
    Last Post: 10th September 2010, 15:19
  3. Replies: 3
    Last Post: 8th July 2010, 07:41
  4. Replies: 4
    Last Post: 11th March 2008, 11:44
  5. Reg - Progress bar
    By suresh in forum Qt Programming
    Replies: 1
    Last Post: 12th December 2006, 15:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.