PDA

View Full Version : Complex editor in delegate



achard.ju
11th March 2015, 17:05
Hello everyone.

I have a problem with complex editors created by a delegate to edit field of QTreeView.

The editor contain a QLabel (hidden in this case), a QLineEdit and a QPushButton.
I managed to gave focus to the QLineEdit at editor creation with setFocusProxy(ui.lineEdit)

My remaining problem is when the QLineEdit looses focus (on clic in another part of the application), the editor is not closed, and so the setModelData not called.
The only way to close the editor is to change the current item selected in the TreeView.

I can't figure out where it comes from.

Thanks for your help !

anda_skoa
11th March 2015, 22:06
Your delegate can emit the closeEditor() signal when it wants to let the view know that the editor should no longer be active.

Cheers,
_

achard.ju
13th March 2015, 14:11
Yes but when ?

I tried to installEventFilter on my widget, and on focusOut emit closeEditor() but it does not work.

anda_skoa
13th March 2015, 15:14
Does not work in the sense that the event filter does not get called or that emitting the signal does not work?

Cheers,
_

achard.ju
13th March 2015, 15:50
The eventFilter is called, but never with an event Type FocusOut.

anda_skoa
14th March 2015, 07:41
Ah, ok, this is very strange.

A couple of things you could try:
- QLineEdit::editingFinished(): that signal is also emitted when the line edit loses focus
- QApplication::focusChanged()

Cheers,
_