Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, January 2008
iterate qmenubar/qmenu objects


Message 1 in thread

I am trying to find a way to get a list of qmenu(or qaction) objects in 
a qmenubar, take those objects and recursively iterate through there 
list. Anyone know of a way to do this?

I am using QT 4.3.3 OpenSource edition.

 > Mike

--
 [ signature omitted ] 

Message 2 in thread

Mike Delaney wrote: 
> I am trying to find a way to get a list of qmenu(or qaction) objects
in a qmenubar,
> take those objects and recursively iterate through there list. Anyone
know of a way
> to do this?
>
> I am using QT 4.3.3 OpenSource edition.

Since QMenuBar is a QWidget, you can just call the "actions()" function
to get a QList of actions in the menu.  You can then iterate through the
QList.

If a particular action's QAction::menu() returns a menu pointer, you can
get the action list for that menu using the "actions()" function as
well.  Note that separators are actions as well, you may need to check
QAction::isSeparator() in case you need to ignore these.

Rob

--
 [ signature omitted ]