How to change Icon size in QMenu?
Hi, I can't find how to change the size of icons in QMenu. I don't see any method like "setIconSize()" for QMenu. Simple code:
action = new QAction(icon, "Settings", this);
menu->addAction(action);
All icons that I create like this appear in the menu in small size (a bit smaller than in all other programs). Is it possible somehow to increase the size of icons? I use *.svg and *.png icons of different sizes from 48x48 to 128x128, but when my program runs, all icons have the same default and small size.
Thank you!
Re: How to change Icon size in QMenu?
Quote:
Originally Posted by
alex chpenst
Hi, I can't find how to change the size of icons in QMenu. I don't see any method like "setIconSize()" for QMenu. Simple code:
action = new QAction(icon, "Settings", this);
menu->addAction(action);
All icons that I create like this appear in the menu in small size (a bit smaller than in all other programs). Is it possible somehow to increase the size of icons? I use *.svg and *.png icons of different sizes from 48x48 to 128x128, but when my program runs, all icons have the same default and small size.
Thank you!
On ToolBar i write:
toolBar->setIconSize(QSize(_MAINICONSIZE_,_MAINICONSIZE_)) ;
on the place that you play action i am sure is the same method.....
Re: How to change Icon size in QMenu?
Please search the forums.
QMenu uses styles to decide the correct icon size for the platform in use. You can trick QMenu to use larger icon size with a custom style. For more details, see thread: http://www.qtcentre.org/forum/f-qt-p...cons-4173.html.
Re: How to change Icon size in QMenu?
Thanks a lot, it works fine. With the help of this link and some code from there I came to the following (a bit repeating but more detailed).
1. Find out which style you use:
Code:
std::cout << "Default Style: " << app.style()->metaObject()->className() << std::endl;
In my case QCleanlooksStyle is used by default.
2. make mystyle.h
Code:
#include <QCleanlooksStyle>
{
Q_OBJECT
public:
int pixelMetric
(PixelMetric metric,
const QStyleOption * option
= 0,
const QWidget * widget
= 0 ) const { if (metric
== QStyle::PM_SmallIconSize) { s = 20;
}
return s;
}
};
3. Apply your style to your application
Code:
#include "mystyle.h"
...
app.setStyle(new MyStyle);
That's it. If another style is used, e.g. QPlastiqueStyle, replace QCleanlooksStyle with QPlastiqueStyle and it should work as well.
Re: How to change Icon size in QMenu?
You could have also used a proxy style as proposed in the another thread. :)