I'm not sure, but your eventFilter
is strange. It conflicts with mouse processing of QLineEdit.
- Try to
return QLineEdit::eventFilter();
in default section. - You didn't implement mouse tracking. You should disable it with mouse capture and overloading
mouse*Event();
. Mouse events processing should be disabled while you track manually mouse.
Reason of bug: mouse moving, that processed by QLineEdit overrides text selection that you set in eventFilter. It happens on mouse release.
Possible hotfix (dirty): implement your own slot for set selection and call it via Qt::QueuedConnection. So your direct call of setSelection will be processed after releasing of mouse.