I'm New to QT so please excuse my ignorance.
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.
#ifndef SVGPUSHBUTTON_H
#define SVGPUSHBUTTON_H
#include <QtGui>
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->size() );
}