QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsfocuswatcher.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsfocuswatcher.h
3 -----------------
4 Date : April 2016
5 Copyright : (C) 2016 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#include "qgsfocuswatcher.h"
17#include "moc_qgsfocuswatcher.cpp"
18#include <QEvent>
19
21 : QObject( parent )
22{
23 Q_ASSERT( parent );
24 parent->installEventFilter( this );
25}
26
27bool QgsFocusWatcher::eventFilter( QObject *, QEvent *event )
28{
29 switch ( event->type() )
30 {
31 case QEvent::FocusIn:
32 emit focusChanged( true );
33 emit focusIn();
34 break;
35 case QEvent::FocusOut:
36 emit focusChanged( false );
37 emit focusOut();
38 break;
39 default:
40 break;
41 }
42 return false;
43}
void focusIn()
Emitted when parent object gains focus.
void focusChanged(bool focused)
Emitted when parent object's focus changes.
void focusOut()
Emitted when parent object loses focus.
bool eventFilter(QObject *obj, QEvent *event) override
QgsFocusWatcher(QObject *parent)
Constructor for QgsFocusWatcher.