Simulation click() for QMessageBox::question don't work properly
-
I have a wrapper for QMessageBox::question
@bool Ask( const QString& text )
{
QMessageBox::StandardButton res;res = QMessageBox::question( nullptr, QObject::tr( "Confirm Action" ), text, QMessageBox::Yes | QMessageBox::No);
return res == QMessageBox::Yes;
}@And code that simulates pushing Ok button in the test
@QList<QPushButton*> allPButtons = dialog->findChildren<QPushButton*>();
for( auto it : allPButtons )
{
if( dialog->buttonRole( it ) == QMessageBox::YesRole )
{
it->click();
break;
}
}@It closes the dialog, BUT the result (res variable) is QMessageBox::No.
So the Ask function returns false.What need to fix to get QMessageBox::Yes in the result of QMessageBox::question;
PS: when user clicks the Ok button by mouse - all works properly.