title: implement a progress dialog by QDialog
body: <p>I'm using QT to implement some UI program.
  In this program I need a progress dialog.  I tried to use the build-in QProgressDialog, it works fine but in my case I need to confirm (with another dialog) when the "cancel button" is clicked. </p>
  
  <p>In QProgressDialog once the cancel button is clicked, the progress dialog will be canceled, so, I tried to implement my own progress dialog (very simple, a dialog with progress bar). However, if I use my own progress dialog, there is some problems. It cannot be moved or clicked. Once I tried to move it and the dialog loss its focus, the progress bar won't update any more and it cannot gain the focus again.  I tried to set different Modality, but either Qt::ApplicationModal or Qt::WindowModal has the same situation.</p>
  
  <p>follows is my progress dialog class, if someone knows how to modify QProgressDialog to meet the confirm requirement or where is the problem in my code.</p>
  
  <p>header:</p>
  
  <pre><code>class Dialog : public QDialog
  {
      Q_OBJECT
  
  public:
      explicit Dialog(QWidget *parent = 0);
      ~Dialog();
  
      void setRange(int minimum, int maximum);
      void setValue(int value);
      void setLabelText(QString labtext);
      bool wasCanceled();
  
  private:
      Ui::Dialog *ui;
      bool cancelStatus;
  
  private slots:
      void cancel();
  };
  </code></pre>
  
  <p>Source：</p>
  
  <pre><code>#include "dialog.h"
  #include "ui_dialog.h"
  
  Dialog::Dialog(QWidget *parent) :
      QDialog(parent),
      ui(new Ui::Dialog)
  {
      ui-&gt;setupUi(this);
      cancelStatus = false;
      ui-&gt;progressBar-&gt;setRange(0,1);
      ui-&gt;progressBar-&gt;setValue(0);
      //this-&gt;setWindowModality(Qt::WindowModal);
      show();
  }
  
  Dialog::~Dialog(){
      delete ui;
  }
  
  void Dialog::setRange(int minimum, int maximum){
      ui-&gt;progressBar-&gt;setRange(minimum,maximum );
  }
  
  void Dialog::setValue(int value){
      this-&gt;ui-&gt;progressBar-&gt;setValue(value);
  }
  
  void Dialog::setLabelText(QString labtext){
      this-&gt;ui-&gt;label-&gt;setText(labtext);
  }
  
  void Dialog::cancel(){
  // pop up the confirm dialog here
  // cancelStatus = true if the confirm dialog is accepted, else do nothing .
  }
  
  bool Dialog::wasCanceled(){
      return cancelStatus;
  }
  </code></pre>