Solved How to adjust order of menu items?
-
For menu "recent files", if a path is already in the menu but not the first one, it should be move to the first.
-
@jronald said in How to adjust order of menu items?:
Removing an action from menu will delete the action from memory, right?
No. Untested, but did you see void QWidget::removeAction(QAction *action), @artwaw suggested that too:
Removes the action action from this widget's list of actions.
I would expect it to preserve everything for re-insert. removeAction and insertAction reference each other.
-
@jronald you can use
insertAction()
method. When building your menu though it might be faster to sort your strings first and then build actions in the order of the strings. -
@artwaw said in How to adjust order of menu items?:
@jronald you can use
insertAction()
method. When building your menu though it might be faster to sort your strings first and then build actions in the order of the strings.insertAction()
can insert a new action, how tomove
an action? -
@jronald
removeAction()
and then insert it at the desired position? -
@jronald
Since there is no "move", insert in desired order or use remove followed by re-insert if you have to move later on. -
@artwaw said in How to adjust order of menu items?:
@jronald removeAction() and then insert it at the desired position?
@JonB said in How to adjust order of menu items?:
Since there is no "move", insert in desired order or use remove followed by re-insert if you have to move later on.
Removing an action from menu will delete the action from memory, right?
Then it needs to new an action and connect it with a handler, anyway to save this? -
@jronald said in How to adjust order of menu items?:
Removing an action from menu will delete the action from memory, right?
No. Untested, but did you see void QWidget::removeAction(QAction *action), @artwaw suggested that too:
Removes the action action from this widget's list of actions.
I would expect it to preserve everything for re-insert. removeAction and insertAction reference each other.