I have a simple pop-up that requires a user selection (or cancellation) that uses a QMenu, and I simply want which item in the menu (first or second/0 or 1) was selected, but I do not see a member function of QAction that gives me this.
Here is the code that pops-up the menu and for now writes a debug statement with the text of the menu item selected being shown:
QMenu menu( this );
QAction *result;
menu.addAction( "Choice 1" );
menu.addAction( "Choice 2" );
if( nullptr == ( result = menu.exec( QCursor::pos() ) ) )
qDebug() << "Selection cancelled";
else
qDebug() << "Choice selected:" << result->text();
How do I simply get a numberic response of 0 or 1 for these choices?