title: Qt How to update GUI in the loop
body: <p>I need to update screen to show how button is moving.
  Here is my code:</p>
  
  <pre><code>void mouseReleaseEvent(QMouseEvent *event){
      double b=(button-&gt;x()*event-&gt;y())/(button-&gt;x()-1);
      double k=(button-&gt;y()-b)/button-&gt;x();
      int time=0;
      fnl=false;
      if(event-&gt;button()==Qt::LeftButton)
      {
          while(!fnl)
          {
              int mX=button-&gt;x()-1;
              int mY=k*(button-&gt;x()-1)+b;
              button-&gt;setText(QString::number(b));
              button-&gt;move(mX,mY);
              QThread::sleep(1);
              //here I need to update screen and show button
          }
  
      }
  }
  </code></pre>
  
  <p>But it does not update GUI. It simply plays inside the loop.</p>