forked from zuotian0222/InputMethod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.cpp
More file actions
32 lines (28 loc) · 749 Bytes
/
widget.cpp
File metadata and controls
32 lines (28 loc) · 749 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
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
keyboard = new KeyBoard();
keyboard->resize(600,300);
ui->lineEdit->installEventFilter(this);
ui->lineEdit_2->installEventFilter(this);
}
Widget::~Widget()
{
delete keyboard;
delete ui;
}
bool Widget::eventFilter(QObject *w, QEvent *e)
{
if(w->inherits("QLineEdit") && e->type() == QEvent::MouseButtonRelease){
QWidget * p = qobject_cast<QWidget *>(w);
keyboard->setEdit(p);
QPoint posA = p->mapToGlobal(QPoint(0, 0));
keyboard->move(posA.x(),posA.y()+p->height());
keyboard->show();
}
return QWidget::eventFilter(w,e);
}