#ifndef QCUSTOMPUSHBUTTON_H
#define QCUSTOMPUSHBUTTON_H
#include <QWidget>
#include <QPushButton>
class QCustomPushButton : public QPushButton
{
Q_OBJECT
public:
QCustomPushButton(QWidget *parent);
~QCustomPushButton();
//Haved clicked(), pressed(), released ()
protected:
virtual void enterEvent(QEvent* event);
virtual void leaveEvent(QEvent* event);
virtual void focusInEvent(QFocusEvent* event);
virtual void focusOutEvent(QFocusEvent* event);
signals:
void onEnter();
void onLeave();
void inFocus();
void OutFocus();
};
#endif // QCUSTOMPUSHBUTTON_H
#include "QCustomPushButton.h"
QCustomPushButton::QCustomPushButton(QWidget *parent)
: QPushButton(parent)
{
}
QCustomPushButton::~QCustomPushButton()
{
}
void QCustomPushButton::enterEvent(QEvent* event)
{
Q_UNUSED(event);
emit onEnter();
}
void QCustomPushButton::leaveEvent(QEvent* event)
{
Q_UNUSED(event);
emit onLeave();
}
void QCustomPushButton::focusInEvent(QFocusEvent* event)
{
Q_UNUSED(event);
emit inFocus();
}
void QCustomPushButton::focusOutEvent(QFocusEvent* event)
{
Q_UNUSED(event);
emit OutFocus();
}