1 #ifndef QSVGBUTTON_H 2 #define QSVGBUTTON_H 3 4 #include <QWidget> 5 #include <QAbstractButton> 6 #include <QtSvg/QSvgRenderer> 7 #include <QtSvg/QGraphicsSvgItem> 8 #include <QGraphicsView> 9 #include <QGraphicsScene> 10 11 class qSVGButton : public QAbstractButton 12 { 13 Q_OBJECT 14 15 public: 16 explicit qSVGButton(QWidget *parent = 0); 17 explicit qSVGButton(QString buttonFile = "defaultButton.svg", QWidget *parent = 0); 18 explicit qSVGButton(QString buttonFile = "defaultButton.svg", QString buttonDownFile = "defaultButtonDown.svg", QWidget *parent = 0); 19 ~qSVGButton(); 20 21 private: 22 void paintEvent(QPaintEvent *pe); 23 void resizeEvent(QResizeEvent *re); 24 void init(); 25 float myheight, mywidth; 26 QGraphicsView view; 27 QGraphicsScene scene; 28 QGraphicsSvgItem *button, *buttonDown; 29 QSize b,bd; 30 bool hasDown; 31 }; 32 33 #endif // QSVGBUTTON_H 34