I have a custom QTextEdit which overrides ::mouseMoveEvent(QMouseEvent *e)
and ::focusOutEvent(QFocusEvent *e)
. The context of QTextEdit is selectable. In selection mode, when the user exceeds QTextEdit's bounds I want to stop the selection programmatically by doing this in ::mouseMoveEvent:
if(e->pos().y() < 0)
{
QTextEdit::focusOutEvent(new QFocusEvent(QFocusEvent::FocusOut));
}
I figured out that when the user releases the mouse, focusOutEvent is being called immediately.
The problem: Even though I call focusOutEvent programmatically, the focusOutEvent is not called at all. It is called only when the user releases the mouse click. I tried also with mouseReleaseEvent but it's the same problem.
Why the focusOutEvent is not called? What can be done? And if there is another solution to my problem? Thank you!