Search code examples
qtqt-contextmenu

In Qt, for a context menu item, how to hide the space of the icon


I am adding a context menu using QAction for a widget. Now, there is some white space beside the text of the action. I assume this is the space where the QIcon association with the QAction should have been there. Now how do I hide this space. I tried doing:

action->setIcon(QIcon());

but still does not seem to work.

Kindly let me know if you have the way to remove that space before the text.


Solution

  • I don't know if there is a way specific to the action or the menu, but you could probably remove it using a style.