Last active
August 29, 2015 14:05
-
-
Save radicaljims/cd4aa873664ef1895c5e to your computer and use it in GitHub Desktop.
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
class FocusInFilter : public QObject | |
{ | |
Q_OBJECT | |
public: | |
FocusInFilter(QObject *parent = nullptr) : QObject(parent) | |
{} | |
signals: | |
void focussed(); | |
protected: | |
bool eventFilter(QObject *obj, QEvent *event) | |
{ | |
if(event->type() == QEvent::FocusIn) | |
{ | |
emit focussed(); | |
} | |
return QObject::eventFilter(obj, event); | |
} | |
private: | |
}; | |
------ | |
focus_filter = new FocusInFilter(this); | |
connect(focus_filter, SIGNAL(focussed()), this, SLOT(doStuff())); | |
auto widget_children = this->findChildren<QWidget*>(); | |
foreach(QWidget *child, widget_children) | |
{ | |
child->installEventFilter(focus_filter); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment