Created
July 6, 2012 20:47
-
-
Save rla/3062660 to your computer and use it in GitHub Desktop.
MouseClickEventFilter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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