1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-01-27 06:54:20 +00:00

Clear LineEdit on ESC

This commit is contained in:
silverqx 2018-05-23 22:41:13 +02:00 committed by silver
parent b09e32ebc0
commit ea404445f6
No known key found for this signature in database
GPG Key ID: 7AF60D549724DEEF
2 changed files with 9 additions and 0 deletions

View File

@ -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);
}

View File

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