如何替换菜单中的操作?

use*_*020 2 c++ qt menu

例如,我有一个菜单并在其中的某处添加一个操作。一段时间后,我想用新的操作替换该操作,因为它变得无效。如何实施?

QMenu* menu = new QMenu(this);
... 
QAction* action = menu->addAction("text");
...

QAction* newAction = new QAction(menu);

// how to replace?
Run Code Online (Sandbox Code Playgroud)

use*_*165 5

// To replace action with yetAnotherAction:

 menu->insertAction(action,yetAnotherAction);
 menu->removeAction(action);
Run Code Online (Sandbox Code Playgroud)