How to change the IconSize of QToolButton.
button1->setIcon(QIcon("download.jpg"));
button1->setFixedSize(100,100);
By using above code button size is getting change but icon inside the button is not changing.
How about
button1->setFixedSize(100,100);
button1->setIconSize(QSize(100, 100));
If your button lays on the toolbar then use
toolBar->setIconSize(QSize(100, 100));
instead of button icon size changing.
If you want to have different sizes on the toolbar then vary them with setFixedSize()
. Of course the maximal of them should be QToolBar icon size.
From https://qt-project.org/doc/qt-5/qabstractbutton.html#iconSize-prop
You can try using
button1->setIconSize(QSize(100, 100));
Or you can give the button1
size as an argument,
button1->setIconSize(button1->size());
The only downside with this method is that the icons will not be scaled by more than 100% of their original size. If you want icons scaled up, you can try to reimplement the QToolButton::setIconSize
method or, as a quick and dirty fix, resize the images using an image editor.
In case of using a QToolBar, use QToolBar::setIconSize
method which sets the maximum size icons in the toolbar can have. The icons themselves can be of different size.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With