How to change menu's icon's size
-
If you are using QToolBar, it has a iconSize property. For menu, though, refer "link here":http://www.qtcentre.org/threads/15742-How-to-change-Icon-size-in-QMenu
-
AFAIK QMenu only gets it's icon size from the style it has set.
So you would need to subclass "QProxyStyle":http://qt-project.org/doc/qt-4.8/qproxystyle.html#details and reimplement pixelMetric() method:Something like this:
@
class MyProxyStyle : public QProxyStyle
{
public:
int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, const QWidget * widget = 0 ) const
{
if (metric == QStyle::PM_SmallIconSize)
return 32;
else
return QProxyStyle::pixelMetric(metric, option, widget);
};
@
Haven't tried it though.Please also note the hint in the docs:
[quote]
Warning: The common styles provided by Qt will respect this hint, because they call QStyle::proxy(), but there is no guarantee that QStyle::proxy() will be called for user defined or system controlled styles. It would not work on a Mac, for example, where menus are handled by the operating system.
[/quote] -
ya,i try your code.it can change icon's size,but when icon's size get big,the QMenu'icon can covered QMenu's text,how to set space
between icon and text.
i find a stylesheet's code ,QMenu::item { padding: xx xx xx xx;},it can change space bewteen icon and text. it can use code instead of stylesheet?