title: How to wait for keyboard input in Qt (c++)
body: <p>When I push a button I want it to:</p>
  
  <p>-change my label,</p>
  
  <p>-wait for fixed time OR for any key pressed by user (let's say SPACE)</p>
  
  <p>-then change label again.</p>
  
  <hr>
  
  <p>For now I have this:</p>
  
  <pre><code>void MainWindow::on_PushButton_clicked()
  {
      ui-&gt;labeltext-&gt;setText("bla");
  
      SLEEP(3000);
  
      ui-&gt;labeltext-&gt;setText("blabla");
  }
  </code></pre>
  
  <p>where my SLEEP function:</p>
  
  <pre><code>void SLEEP(int ms){
    QEventLoop loop;
    QTimer::singleShot(ms, &amp;loop, SLOT(quit()) );
    loop.exec();
  };
  </code></pre>
  
  <p>is working OK.</p>
  
  <p>How to implement waiting for key?</p>
  
  <hr>
  
  <p>As  Thomas Matthews suggested i tried to use timer, but i'm stuck with creating it.
  I add<code>QTimer timer1</code> to header and in source<code>timer1.setSingleShot(1)</code> while creating mainwindow and in my button slot: </p>
  
  <pre><code>timer1.start(5000);
  connect(timer1, SIGNAL(timeout()), ui-&gt;labeltext, SLOT(setText("blabla")));
  </code></pre>
  
  <p>but I get error</p>
  
  <pre><code>C2664: 'QMetaObject::Connection QObject::connect(const QObject *,const char *,const QObject *,const char *,Qt::ConnectionType)' : cannot convert parameter 1 from 'QTimer' to 'const QObject *'
  </code></pre>
  
  <p>Also using timer straight in button slot: </p>
  
  <pre><code>QTimer *timer2 = new QTimer(this);
  connect(timer2, SIGNAL(timeout()),ui-&gt;labeltext,SLOT(setText("blabla")));
  timer2-&gt;setSingleShot(1);
  timer2-&gt;start(2000);
  </code></pre>
  
  <p>has no efects (it compiles at least but is not changing label).</p>
  
  <p>What should I do?</p>