| 45 | } |
| 46 | |
| 47 | void CAutoCompleteLineEdit::keyPressEvent(QKeyEvent *event) |
| 48 | { |
| 49 | switch (event->key()) { |
| 50 | case Qt::Key_Tab: |
| 51 | case Qt::Key_Right: |
| 52 | // 按下Tab或右箭头接受建议 |
| 53 | acceptSuggestion(); |
| 54 | event->accept(); |
| 55 | return; |
| 56 | case Qt::Key_Escape: |
| 57 | // ESC取消建议 |
| 58 | hideSuggestion(); |
| 59 | event->accept(); |
| 60 | return; |
| 61 | default: |
| 62 | QLineEdit::keyPressEvent(event); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | void CAutoCompleteLineEdit::focusInEvent(QFocusEvent *event) |
| 67 | { |