user1899020
user1899020

Reputation: 13575

how to replace an action in a menu?

For example, I have a menu and add an action in it somewhere. And after some time I want to replace the action by a new one because it becomes invalid. How to implement it?

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

QAction* newAction = new QAction(menu);

// how to replace?

Upvotes: 2

Views: 564

Answers (1)

user2672165
user2672165

Reputation: 3049

// To replace action with yetAnotherAction:

 menu->insertAction(action,yetAnotherAction);
 menu->removeAction(action);

Upvotes: 5

Related Questions