QMenu always displays icons aty 16x16 px
Hi - I am using QMenu, and I am using a large font in the menu. I am providing 24x24 pixel icons to the QMenu when I add actions to it, but when the menu renders, my icons have been "downsized" to 16x16 pixels, and look too small next to my larger menu text.
I could not find out how to set the icon size -- I tried setting the style of the menu to this style sheet, but no joy. Any help is much appreciated!
QMenu::item { padding: 2px 32px 2px 20px; }
QMenu::item:selected { background-color: blue; color: white }
QMenu::icon { width:24px; height:24px; }
QMenu::indicator { width:24px; height:24px; }
- Greg
Re: QMenu always displays icons aty 16x16 px
I guess you will need to provide a new style. You can derive it from the style classes in Qt.
Re: QMenu always displays icons aty 16x16 px
Thank you for the pointer... here's what I tried.
I derived my own style from QPlastiqueStyle and overrode the pixelMetric() function. QPlastiqueStyle calls its pixelMetric() method when it is drawing a menu item, to find out the pixel metrics for PM_SmallIconSize. My overridden class re-implements the virtual pixelMetrics like this:
Code:
int MyStyle
::pixelMetric (PixelMetric metric,
const QStyleOption* option,
const QWidget* widget
) {
qDebug () << "my menu style pixelMetric called!";
if (metric == PM_SmallIconSize)
{
return 24;
}
else
{
}
}
Next, I instantiate an object of type MyStyle and pass it to my QMenu's setStyle method:
Code:
MyStyle myStyle;
menu.setStyle (&myStyle);
However, when I pop up that menu, my pixelMetric function (in my derived class) never gets called -- and the icon is still displayed at 16x16. Any suggestions?
Thanks
Greg