0

I'm writing a test app that would test if the displayed form is the correct form. This is after pressing a key on a menu. Here's a code block where I'm getting a segmentation fault.

std::auto_ptr<MyForm> pForm(new MyForm(3,3));  
QTest::keyPress(pForm.get(), Qt::Key_0);  
QWidget *pWin = QApplication::activeWindow(); 
QCOMPARE(pWin->windowTitle(), QString("My Second Menu")); 

Questions:

  • Is it really possible to get the currently active window when you are just simulating key presses?
  • I'm getting a null pointer when using activeWindow, is there anyway you could get the handle of the window that's supposed to show on the screen upon a keypress?

Thanks...

4

1 に答える 1

0

フランクは正しかった。ウィンドウは同期的にアクティブ化されていません。keyPress のパラメーターである遅延を追加すると、問題は解決しました。ありがとうフランク!

于 2010-11-22T10:49:04.997 に答える