[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Accessing a (sub)menu defined in an XmlGui ui.rc file
From:       Tobias Leupold <tobias.leupold () gmx ! de>
Date:       2021-01-13 9:39:48
Message-ID: b907f684-10e0-44ad-966c-71ad81337203 () gmx ! de
[Download RAW message or body]

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 ...

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 can access the "someAction" action like the other ones like so:

    auto *someAction
        = actionCollection()->addAction(QStringLiteral("someAction"));
    someAction->setText(i18n("Some action"));
    someAction->setIcon(QIcon::fromTheme(QStringLiteral("some-icon")));
    connect(someAction, &QAction::triggered, this, 
&SomeClass::someFunction);

and so on.

But how can I get the "bar" QMenu (or it's respective QAction)? So that I 
can
e. g. disable or hide the menu, or assign an icon? For manually defined 
menus,
this would be as easy as "auto *action = menu->menuAction();" ...

Sorry if I overlooked something obvious, but I have no idea how to do this.
Thanks in advance for all help!

Cheers, Tobias

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic