Accessing a (sub)menu defined in an XmlGui ui.rc file
David Hurka
david.hurka at mailbox.org
Wed Jan 13 22:53:20 GMT 2021
On Wednesday, January 13, 2021 10:39:48 AM CET Tobias Leupold wrote:
> Hi list :-)
>
> I have a problem with a KXmlGuiWindow and I honestly can't find respective
> docs or howtos/tutorials. I hope someone here can help me ...
I faced the same problem... :(
> It's a allegedly basic task: How can I access a submenu (or better: a
> submenu's QAction) for a menu defined in a ...ui.rc file?
>
> If I define the submenu like so:
>
> <MenuBar>
> <Menu name="foo" >
> <Menu name="bar">
> <text>Some text</text>
> <Action name="someAction"/>
> </Menu>
> </Menu>
> </MenuBar>
I probably don’t understand properly what you need. But if you want to modify
the action which contains the menu "bar", you could use KActionMenu.
Change the ui.rc to:
<MenuBar>
<Menu name="foo" >
<Action name="bar"/>
</Menu>
</MenuBar>
then create a KActionMenu called "bar" in your KActionCollection, set its icon
etc., and populate its menu.
Of course this moves UI definition from ui.rc to C++ code, but it looks like
you want to modify the menu at runtime.
More information about the kde-devel
mailing list