You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Tuesday, June 8th 2004, 3:06pm

Retrieving pointer to qpopupmenu

Hello all,

I have a problem with building a dynamic menu.

I need to on the aboutToShow() signal for a qpopupmenu populate it with entries, as well as sub menus. This would be no problem if I had a pointer to the menu, but I do not because all the menus are built with KDE's XMLGUI.
So, I need a method to retrieve a pointer to a qpopupmenu, and all I got is its menu identifier(not index or Id). I have a qmenubar(kmenubar) via QMainWindow(kmainwindow). Tricky, AFAICT..

I know building dynamic menus are generally a bad idea, but I have a valid reason(honest!).

Any ideas?

Thanks in advance,




Posts: 29

Location: Moulins France

Occupation: Software ingeneering

  • Send private message


Tuesday, June 8th 2004, 5:27pm

RE: Retrieving pointer to qpopupmenu

If you know the name of your menu, you can always retrieve it exploring children from QMenuBar.
The QObject::children() method reports a QObjectList you can iterate in. Some KDE folks could tell you if there is something simpler, however.
Never patch not working code. Rewrite it !
Never patch badly designed classes. Recreate them cleanly.
(Excerpts from Computing Bible)

Home of the Lab project



Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message


Tuesday, June 8th 2004, 10:38pm

I think you can use KXMLGUIFactory::container() to get a pointer to all containers (menus and toolbars) defined in the application's XML GUI file.

Qt/KDE Developer
Debian User