title: Qt: creating an "svg image button"
body: <p>I'm new to Qt so please excuse my ignorance.</p>
  
  <p>I am attempting to create a an 'svg image button' with QSizePolicy::Preferred for both horizontal and vertical.
  That part works. When the window is resized, the button grows and shrinks exactly how I want... But the image within the button stays the same size.
  I would like the image to scale with the button. I tried to overload resizeEvent, and call setImageSize, but that infinitely recurses.</p>
  
  <pre><code>#ifndef SVGPUSHBUTTON_H
  #define SVGPUSHBUTTON_H
  
  #include &lt;QtGui&gt;
  
  class SVGPushButton : public QPushButton
  {
  public:
      SVGPushButton(QString path, QString name = "");
      ~SVGPushButton();
  
      void resizeEvent(QResizeEvent * event);
  private:
  };
  
  #endif // SVGPUSHBUTTON_H
  
  #include "SVGPushButton.h"
  
  SVGPushButton::SVGPushButton(QString svgPath, QString name)
  : QPushButton(name)
  {
      QIcon icon(svgPath);
      setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
      setFlat(true);
      setIcon(icon);
  }
  
  SVGPushButton::~SVGPushButton()
  {}
  
  void SVGPushButton::resizeEvent(QResizeEvent * event)
  {
      setIconSize( event-&gt;size() );
  }
  </code></pre>