PDA

View Full Version : How to change the size of icons in the menus of the menu bar ?



daudiam
12th October 2010, 17:48
I can't find a way to change the size of icons in the actions associated with the menus (like New,Open,etc.) I can change the font size of the text associated with the action but not the icon size. I am actually using Jambi but I can easily manipulate Qt's functions to fit on Jambi.

tbscope
12th October 2010, 18:34
http://doc.qt.nokia.com/4.7/qstyleoptionmenuitem.html#maxIconWidth-var

But, be aware that some styles might not use it to get the icon size.

daudiam
12th October 2010, 19:56
Thanks. But the menu class doesn't seem to have any option to set it to an object of QStyleOptionMenuItem. I think the setStyle option might work but QStyleOptionMenuItem is not a style but aids in the style, but I can't understand how to implement it. Can u give a small code that sets the menu's icon width using this class ?

tbscope
12th October 2010, 20:23
http://doc.qt.nokia.com/4.7/qproxystyle.html

daudiam
12th October 2010, 20:59
Thanks. I did this :

1. Created a QProxyStyle object.
2. Created a QStyleOptionMenuItem object called o. Called the function setMaxIconWidth (24)
3. Called the drawControl function called oo. Parameters were CE.MenuBarItem, o and a new QPainter object.
4. Called the menu's setStyle function with oo.

Nothing changed. I wonder that the setMaxIconWidth only sets the maximum width. The fact that I want to increase the size of icons is not getting conveyed by this method, i think.

tbscope
13th October 2010, 05:42
The size of the icon is measured by its width. It is a rectangle. Example: 20x20. The minimum size in some of the styles is 20, so you can't go smaller. But the maximum size is taken from the maximum icon width of the option you set.

I do not have time at the moment, but I'll try to create an example later today (evening on my part of the world). But I can't promise anything.

Note that styles don't need to follow special guidelines. This means that a technique that works with one style, might not work with another. This in turn means that it would be a good idea to create a custom menu style, which you can also do with the proxystyle