forked from zhengtianzuo/QtQuickExamples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQmlKey.cpp
More file actions
37 lines (33 loc) · 811 Bytes
/
QmlKey.cpp
File metadata and controls
37 lines (33 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*!
*@file QmlKey.cpp
*@brief Qml全局按键
*@version 1.0
*@section LICENSE Copyright (C) 2003-2103 CamelSoft Corporation
*@author zhengtianzuo
*/
#include "QmlKey.h"
QmlKey::QmlKey()
{
}
bool QmlKey::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Backspace)
{
emit sKeyBackPress();
return(true);
}
}
if (event->type() == QEvent::KeyRelease)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
if (keyEvent->key() == Qt::Key_Backspace)
{
emit sKeyBackRelease();
return(true);
}
}
return QObject::eventFilter(watched, event);
}