Search code examples
c++qtqtguiqicon

How to change IconSize of QToolButton


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.


Solution

  • 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.