spyder-ide / qtawesome

Iconic fonts in PyQt and PySide applications
https://qtawesome.readthedocs.io/en/latest/index.html
MIT License
802 stars 105 forks source link

Unable to size icon inside qta.IconWidget #168

Closed polygonalize closed 3 years ago

polygonalize commented 3 years ago

I looked at the usage example to see how I could size an icon without putting it in a button widget and this works:

spin_widget = qta.IconWidget()
spin_icon = qta.icon('mdi.loading', color='red',
                     animation=qta.Spin(spin_widget))
spin_widget.setIcon(spin_icon)
spin.widget.setIconSize(QSize(128, 128))

But if I try to add my an icon without animations, I cannot get the desired size. It will show in its default size. For example, this code will not show the icon in the size I desire:

spin_widget = qta.IconWidget()
spin_icon = qta.icon('mdi.loading', color='red')
spin_widget.setIcon(spin_icon)
spin.widget.setIconSize(QSize(128, 128))

Is there a workaround that doesn't require setting the icon in a QPushButton?

dalthviz commented 3 years ago

Hi @diagonalize thanks for the feedback! Checking seems like for actually applying the size change the update method should be call (and I think that's why using an animation enables to actually resize the icon). Could you try to call spin.widget.update() and see if that helps? Let us know!

polygonalize commented 3 years ago

Hello @dalthviz. The update() method did indeed fix my issue.

Thank you very much!