How to receive notifications when a QList has been changed?
Consider this code:
Code:
bar.
actions().
append(new QAction("Hello World"));
QMenuBar returns a QList of QAction pointer, after I appended a new action, how does QMenuBar be notified on the change, so that it can update the UI accordingly?
I also tried to create a class that inherits from QList and I found no way to be notified when the list is changed.
Thanks in advance.
Re: How to receive notifications when a QList has been changed?
You're going about it backwards. You add an action to QMenuBar or QMenu and then get a new QList of QActions.
From the docs:
Quote:
A menu consists of a list of action items. Actions are added with the addAction(), addActions() and insertAction() functions. An action is represented vertically and rendered by QStyle. In addition, actions can have a text label, an optional icon drawn on the very left side, and shortcut key sequence such as "Ctrl+X".
The existing actions held by a menu can be found with actions().