title: Qt: How do I get the currently running window?
body: <p>I'm writing a test app which simulates key presses and I would like to get what window is displayed after each key presses. Here's the code block. </p>
  
  <pre><code>std::auto_ptr&lt;MyForm&gt; pForm(new MyForm(3,3)); 
  QTest::keyPress(pForm.get(), Qt::Key_0); 
  </code></pre>
  
  <p>After pressing 0 here, A window is gonna show up and I would like to check what window it is so I could QCompare/evaluate it later. </p>
  
  <p>Any Ideas?</p>
  
  <p><strong>Updated:</strong></p>
  
  <p>I'm getting a segmentation fault when I use </p>
  
  <pre><code>std::auto_ptr&lt;MyForm&gt; pForm(new MyForm(3,3)); 
  QTest::keyPress(pForm.get(), Qt::Key_0); 
  QWidget *pWin = QApplication::activeWindow();
  QCOMPARE(pWin-&gt;windowTitle(), QString("My Second Menu"));
  </code></pre>