maybe this code helps you. Create a QPushButton, Set an icon for it and use this code :
YourQPushButton->setFlat(true);
Update :
MyPushButton.h:
#ifndef MYPUSHBUTTON_H
#define MYPUSHBUTTON_H
#include <QLabel>
class MyPushButton : public QLabel
{
Q_OBJECT
public:
explicit MyPushButton(QWidget *parent = 0);
signals:
void clicked();
protected:
void mouseReleaseEvent(QMouseEvent *ev);
};
#endif // MYPUSHBUTTON_H
MyPushButton.cpp
void MyPushButton::mouseReleaseEvent(QMouseEvent *ev)
{
emit clicked();
}
How to use :
MyPushButton btn;
btn.setPixmap(QPixmap(":/rm.png"));
QObject::connect(&btn, SIGNAL(clicked()), qApp, SLOT(quit()));
btn.show();
You can even add this function to MyPushButton
class to be more productive :)
void MyPushButton::setIcon(QPixmap px, int w, int h)
{
setPixmap(px.scaled(w, h));
}