Question

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.

Was it helpful?

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.

OTHER TIPS

You don't say which platform. But on Mac you can turn off menu items altogether with:

qt_mac_set_menubar_icons( false );

You didn't mention the version of Qt you are using but version 4.4.3's QAction allows you to hide the icon:
http://doc.trolltech.com/4.4/qaction.html#iconVisibleInMenu-prop

You can also try using the QAction::QAction ( const QString & text, QObject * parent ) constructor:
http://doc.trolltech.com/4.4/qaction.html#QAction-2 (4.4.3)
http://doc.trolltech.com/4.0/qaction.html#QAction-2 (4.0)
http://doc.trolltech.com/3.3/qaction.html#QAction-2 (3.3)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top