Accessing a (sub)menu defined in an XmlGui ui.rc file

Alexander Semke alexander.semke at
Wed Jan 13 20:18:57 GMT 2021

Hi Tobias,

> 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 ...
> [...]
> 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,

In your main window class deriving from KXMLGuiWindow you do the following:

auto* factory = this->guiFactory();
auto* menu = dynamic_cast<QMenu*>(factory->container("bar", this));
if (menu) {
    //add your logic here with the menu pointer

Is this what you're looking for?


More information about the kde-devel mailing list