-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmylineedit.cpp
More file actions
43 lines (37 loc) · 1.19 KB
/
mylineedit.cpp
File metadata and controls
43 lines (37 loc) · 1.19 KB
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
38
39
40
41
42
43
#include "mylineedit.h"
#include <QDebug>
MyLineEdit::MyLineEdit(QWidget *parent) : QLineEdit(parent) {
//wordList = parent->parentWidget()->findChild<WordList *>("listWidget");
mainWindow = (MainWindow *)(parent->parentWidget()->parentWidget()->parentWidget());
//mainWindow.setLineEdit(this);
connect(this, SIGNAL(textEdited(const QString &)),
this, SLOT(storeOriginal(const QString &)));
}
MyLineEdit::~MyLineEdit() {}
void MyLineEdit::storeOriginal() {
originalString = text();
}
void MyLineEdit::storeOriginal(const QString & str) {
originalString = str;
}
void MyLineEdit::clearTextBox() {
setText("");
mainWindow->dropDownClear();
}
void MyLineEdit::keyPressEvent(QKeyEvent *event)
{
switch(event->key()) {
case Qt::Key_Down: // move down highlighter of wordList
mainWindow->dropDownSelNext();
break;
case Qt::Key_Up: // move up highlighter of wordList
mainWindow->dropDownSelPrev();
break;
case Qt::Key_Return:
mainWindow->dropDownClear();
break;
default:
// default handler for event
QLineEdit::keyPressEvent(event);
}
}