I'm working on a custom Qt line edit that allows you to edit the text only if you double click it. When it is double clicked, QLineEdit is getting enabled for text editing. Once you press enter or tab it gets in read only mode again.

One more requirement which I want to implement - is that if the user clicks anywhere in the application window or outside application window, the QLineEdit should become read only again(it should leave the edit mode). This works in some cases. Specifically, it works if I click on anything that is capable of text entry. Other portions of the window don't work as expected.

If I'll click on a blank portion(parent frame) of the application window, QLineEdit retains its focus. How can I remove its focus in these cases?

Actually the problem is I am not getting focusOut when clicking outside on parent window? Can you give me proper direction please...