title: How to use a QProgressBar
body: <p>I am trying to use a progress bar qt creator as a battery image, so I need to be able to control the progress bar(with a variable called my_value that I will change afterward).
  To be more precise,I would like to be able to set from the program the value of the progress bar and have it actually changed and appear on the screen.
  So far, I am rather lost : 
  -I created a progress bar named battery in the .ui file. 
  - I have not changed anything from the header file(that is automatically generated), but it this code : </p>
  
  <pre><code>#ifndef MAINWINDOW_H
  #define MAINWINDOW_H
  
  #include &lt;QMainWindow&gt;
  
  namespace Ui {
  class MainWindow;
  }
  
  class MainWindow : public QMainWindow
  {
      Q_OBJECT
  
  public:
      explicit MainWindow(QWidget *parent = 0);
      ~MainWindow();
  
  private:
      Ui::MainWindow *ui;
  };
  
  #endif // MAINWINDOW_H
  </code></pre>
  
  <p>-Here is my main.cpp file : </p>
  
  <pre><code>include "mainwindow.h"
  #include &lt;QApplication&gt;
  #include &lt;QProgressBar&gt;
  int main(int argc, char *argv[])
  {
      QApplication a(argc, argv);
      QProgressBar battery;
      int my_value=10;
      battery.setValue(my_value);
      battery.valueChanged(my_value);
      MainWindow w;
      w.show();
      return a.exec();
  }
  </code></pre>
  
  <p>I tried setValue() and valueChanged(), but neither of them work
  So I tried with the mainwindow.cpp</p>
  
  <pre><code>#include "mainwindow.h"
  #include "ui_mainwindow.h"
  #include &lt;QProgressBar&gt;
  MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;battery-&gt;setValue(10);
      ui-&gt;setupUi(this);
  }
  
  MainWindow::~MainWindow()
  {
      delete ui;
  }
  </code></pre>
  
  <p>but it still does not work. 
  Can someone help me ? </p>
  
  <p>Thank you very much. </p>