title: Qt progressBar getting Unhandled exception how detect when parent widget is done loading
body: <p>im using Qt QProgressBar and place it in the statusBar on my main window 
  Like this in the constructor :</p>
  
  <pre><code>pb = new QProgressBar(statusBar());
  pb-&gt;setTextVisible(false);
  pb-&gt;hide();
  statusBar()-&gt;addPermanentWidget(pb);
  </code></pre>
  
  <p>then im running procsses (web page loadding in this case ) 
  and trying to show the progress with :</p>
  
  <pre><code>connect(ui.webView, SIGNAL(loadProgress(int)), SLOT(setProgress (int)));
  void myMainWindow:: setProgress(int progress)
  {
  pb-&gt;show();
  pb-&gt;setRange(0,100);
  pb-&gt;setValue(progress);
  }
  </code></pre>
  
  <p>But im getting Unhandled  exception when it comes to pb->show()
  I guess it has to do something with loading the parent main windows and then the progress bar 
  I was reading about the QAbstractEventDispatcher and processEvents but not understood how to implement it .</p>
  
  <p>i did small test and put the pb->show() function call in button click signal/slut 
  that means im triggering the pb->show() after the web page and the mainwindows fully loaded and its working fine without the exception. that make me belive there is problem
  with the event processing.  </p>
  
  <p>here is the class :  </p>
  
  <pre><code>class MainWindowMainWindowContainer : public QMainWindow 
  {
      Q_OBJECT
  
  public:
      MainWindowContainer(QWidget *parent = 0);
  
   public slots:
  
      void adjustLocation();
      void changeLocation();
      void adjustTitle();
      void setProgress(int p);
      void finishLoading(bool);
      void finishedSlot(QNetworkReply* reply);
  
  
  private:
      Ui::OnLineBack_mainWindow ui;    
      int progress;
  
      void createWebViewActions();
      QProgressBar *pb;
      void setprogressBar(int progress,bool show);
  
   };
  
  MainWindowContainer::MainWindowContainer(QWidget* parent) : 
      QMainWindow(parent),
  
  {
   ui.setupUi(this);
   progress = 0;
  
  
  createWebViewActions();
  ui.webView-&gt;load(QUrl("www.cnnnn.com"));
  ui.webView-&gt;show();
  
  pb = new QProgressBar(statusBar());
  pb-&gt;setTextVisible(false);
  pb-&gt;hide();
  statusBar()-&gt;addPermanentWidget(pb);
  }
   void MainWindowContainer::createWebViewActions()
  {
      connect(ui.webView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
      connect(ui.webView, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
      connect(ui.webView, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
      connect(ui.webView, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
      connect(ui.webView, SIGNAL(linkClicked(const QUrl&amp;)),this, SLOT(linkClicked(const QUrl&amp;)));
  
  }
  void MainWindowContainer::setProgress(int p)
  {
      progress = p;
      adjustTitle();
  }
   void MainWindowContainer::adjustTitle()
  {
      qApp-&gt;processEvents(); 
  
      pb-&gt;show();
      if (progress &lt;= 0 || progress &gt;= 100)
      {
          QString titl =  ui.webView-&gt;title();
          statusBar()-&gt;showMessage(titl);
          setprogressBar(-1,false);
  
      }
      else
      {
  
          statusBar()-&gt;showMessage(QString("%1 (%2%)").arg(ui.webView-&gt;title()).arg(progress));
          setprogressBar(progress,true);
      }
  }
  
   void MainWindowContainer::finishLoading(bool)
  {   
      progress = 100;
      adjustTitle();
  
  }
   void MainWindowContainer::setprogressBar(int progress,bool show)
  {
       if(show)
      {
          pb-&gt;show();
          pb-&gt;setRange(0,100);
          pb-&gt;setValue(progress);
      }
      else
      {
          pb-&gt;hide();
      } 
  }
  </code></pre>