atrooney-online-2/src/eventfilters.cpp
TrickyLeifa 657145035c Reimplemented unit tests, ...
* Reimplemented unit tests and simplified addition of new tests
* Minimal support of Qt is now 5.15
2024-05-18 00:48:55 +02:00

19 lines
470 B
C++

#include "eventfilters.h"
bool AOLineEditFilter::eventFilter(QObject *obj, QEvent *event)
{
QLineEdit *lineEdit = qobject_cast<QLineEdit *>(obj);
if (event->type() == QEvent::FocusOut && lineEdit != nullptr && preserve_selection)
{ // lost focus
int start = lineEdit->selectionStart();
int len = lineEdit->selectionLength();
if (start != -1 && len != -1)
{
lineEdit->setSelection(start, len);
return true;
}
}
return false;
}