PDA

View Full Version : Need to implement in place line edit, unable to get lose focus of QLineEdit.



Chirag
29th April 2011, 10:23
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...

rsilva
30th April 2011, 14:22
You can set your window to receive focus.
setFocusPolicy(Qt::StrongFocus);

Chirag
2nd May 2011, 06:33
Thanks a lot! It fixed my problem! But I want to know little bit more if there is any side affect of setting strong focus on main window.