Solved Change the icon size to a QAction
-
Maybe but showing your code where you are making your QIcon objects would help a lot.
-
this is the code:
QMenu *menu = new QMenu; for(int i = 0; i < TotalAction; i++) { QAction *action = new QAction(QIcon("icon_path"), "name"); menu->addAction(action); } pushbutton->setMenu(menu);
the I want to resize the icon.. please HELP ME
-
What icon size do you have in mind ?
What is the size of the image you are loading ? -
I want to resize the icon of the QAction, so it can be visible in detail.
The size of the uploaded image is 55x40 pixels -
Then again, what size do you have in mind ?
-
I want the original size of the image. The problem is that the size of the QAction icon is very small, because it resizes that image size
-
One thing that passed me by: you are setting your icon on a menu. The size used for the icon in this case is decided by the style to follow the platform standard. If you want to customise that part you'll have to implement your own style.
-
Or use a QProxyStyle
-
@SGaist show me an example
-
The doc have sample :) Just after important info..
Anyway, what you are after is something like
#include <QProxyStyle> class MyProxyStyle: public QProxyStyle { Q_OBJECT public: MyProxyStyle(QStyle* style = 0) : QProxyStyle(style) { } MyProxyStyle(const QString& key) : QProxyStyle(key) { } virtual int pixelMetric(QStyle::PixelMetric metric, const QStyleOption* option = 0, const QWidget* widget = 0 ) const { switch ( metric ) { case QStyle::PM_SmallIconSize: return 200; // here u want pixmaps size i assume default: return QProxyStyle::pixelMetric( metric, option, widget ); // return default values for the rest } } };
Note that you violate most user interface guidelines by this.
However, i have done it to make menus good for touch activation so it has its use cases but
it also means that you app will not play well with a platform that it self have adjusted heights.
Like for seeing impaired etc.To use
int main(int argc, char* argv[]) { QApplication a(argc, argv); a.setStyle(new MyProxyStyle() ); MainWindow w; w.show(); return a.exec(); }
-
@mrjj All good, but there is a problem which is that in the application I have another menu that I do not want to resize to the icons