0

I'm trying to test with QTest a GUI application. I can access to all the UI elements across the ui_class.h. The problem is, that I've created several QMessageBox on the main program as local variable and I need them to use QTest::mouseClick() when anyone of them appears.

I'm trying to avoid to realocate those QMessageBox if possible, so I tried to get the Widgets with QApplication::topLevelWidgets() and QApplication::allWidgets(), but they were not working because I cannot find any QWidget which inheriths to QMessageBox. Neither is working QApplication::activeWindow() to make click (or press enter, I just wanna go further after clicking or pressing enter).

So, I would need to know how to select that QMessageBox stored as local variable on my GUI application I'm testing, to select it as QWidget.

My stored variables are QMessageBox::StandardButton and QMessageBox::warning

Thanks in advance for the help.

Manuninho
  • 31
  • 1
  • 6

2 Answers2

0

Could you show more code, please? It's not clear: do you use

QMessageBox(QWidget *parent = nullptr)

constructor or something else. May be you might use obj->findChild<T>(name) or qobject_cast()? If you post your code I may try to test it.

eugesh
  • 111
  • 5
0

Well, after trying something else and getting another problem, the easiest workaround for this was to declare all the QMessageBox on the header function as public, so I can access them through the QTest class.
That's the problem of using static messages.

Manuninho
  • 31
  • 1
  • 6