Browse Source

Clear LineEdit on ESC

adaptive-webui-19844
silverqx 7 years ago committed by silver
parent
commit
ea404445f6
No known key found for this signature in database
GPG Key ID: 7AF60D549724DEEF
  1. 8
      src/gui/lineedit/src/lineedit.cpp
  2. 1
      src/gui/lineedit/src/lineedit.h

8
src/gui/lineedit/src/lineedit.cpp

@ -40,3 +40,11 @@ void LineEdit::resizeEvent(QResizeEvent *e) @@ -40,3 +40,11 @@ void LineEdit::resizeEvent(QResizeEvent *e)
const int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
m_searchButton->move(frameWidth, (e->size().height() - m_searchButton->sizeHint().height()) / 2);
}
void LineEdit::keyPressEvent(QKeyEvent *event)
{
if ((event->modifiers() == Qt::NoModifier) && (event->key() == Qt::Key_Escape)) {
clear();
}
QLineEdit::keyPressEvent(event);
}

1
src/gui/lineedit/src/lineedit.h

@ -23,6 +23,7 @@ public: @@ -23,6 +23,7 @@ public:
protected:
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *event) override;
private:
QToolButton *m_searchButton;

Loading…
Cancel
Save