Hi, I dont know if Your problem is exists yet or not, I found this solution:

Qt Code:
  1. void MyTest::testPasswordDialog()
  2. {
  3. QTimer::singleShot(500, this, SLOT(TimeOut()));
  4. QVERIFY(functionThatProducesMessageBox());
  5. }
  6.  
  7. void MyTest::TimeOut()
  8. {
  9. QWidgetList allToplevelWidgets = QApplication::topLevelWidgets();
  10. foreach (QWidget *w, allToplevelWidgets) {
  11. if (w->inherits("QMessageBox")) {
  12. QMessageBox *mb = qobject_cast<QMessageBox *>(w);
  13. QTest::keyClick(mb, Qt::Key_Enter);
  14. }
  15. }
  16. }
To copy to clipboard, switch view to plain text mode