Reputation: 533
When I add a pop up menu in Qt as follows:
QMenu menu(widget);
menu.addAction("AAA");
menu.exec(eventPress->globalPos());
How do I control "AAA" action events. e.g. do something when "AAA" is clicked.
Upvotes: 0
Views: 439
Reputation: 1684
You can overloaded addAction.
From Qt assistant
This convenience function creates a new action with the text text and an optional shortcut shortcut. The action's triggered() signal is connected to the receiver's member slot. The function adds the newly created action to the menu's list of actions and returns it.
MyClass::Popup()
{
QMenu menu(widget);
menu.addAction("AAA", this, SLOT(burnCase()));
menu.exec(eventPress->globalPos());
}
// This is your slot
MyClass::burnCase()
{
}
Upvotes: 1