Skip to content

Instantly share code, notes, and snippets.

@rla
Created July 6, 2012 20:47
Show Gist options
  • Save rla/3062660 to your computer and use it in GitHub Desktop.
Save rla/3062660 to your computer and use it in GitHub Desktop.
MouseClickEventFilter
// Header
class MouseClickEventFilter : public QObject
{
Q_OBJECT
public:
explicit MouseClickEventFilter(QObject *parent = 0);
signals:
void clicked();
protected:
virtual bool eventFilter(QObject *object, QEvent *event);
};
// Source
MouseClickEventFilter::MouseClickEventFilter(QObject *parent) :
QObject(parent)
{
}
bool MouseClickEventFilter::eventFilter(QObject *, QEvent *event)
{
if (event->type() == QEvent::MouseButtonRelease)
{
emit clicked();
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment