btn = new QPushButton(QIcon(":shut.png"),"")
class Button : public QPushButton { public: Button(QIcon icon,QString str) : QPushButton(icon,str) {} protected: virtual void resizeEvent(QResizeEvent* event) {// setIconSize(event->size()); }};
C++ (Qt)void resizeEvent(QResizeEvent* event){ QStyleOptionButton opt; initStyleOption( &opt ); int bm = style()->pixelMetric( QStyle::PM_ButtonMargin, &opt, this ); int fw = style()->pixelMetric( QStyle::PM_DefaultFrameWidth, &opt, this ) * 2; setIconSize( QSize( width() - ( bm + fw ), height() - ( bm + fw ) ) );}
C++ (Qt)void resizeEvent(QResizeEvent* event){ if( in_resize ) return; in_resize = true; ... in_resize = false;}