PDA

View Full Version : Closing QCompleter when QLineEdit loses focus



mathieuS
22nd July 2011, 22:57
Hi,

I have a QLineEdit on which I set a QCompleter in popup mode, to edit an item in a QTableView. I'd like the editing to start on the next item when I press the tab key. This works fine if I first close the completer, by either clicking on it or pressing return, but not when the QLineEdit simply loses focus.

Would someone have a workaround ? (BTW, this works fine with CurrentChanged edit trigger set... but I don't like it.)

Thanks,
Mathieu

high_flyer
25th July 2011, 11:31
You can re implement focusOutEvent()...

mathieuS
26th July 2011, 18:14
Thanks high_flyer, but it seems the view closes each editor before the QLineEdit is destroyed...

So, I simply implemented a slot in the view, e.g. lineEditDestroyed() and connected it to the destroyed() signal of the QLineEdit. I this slot, I manually call edit() on the current index.