4

I have QStyledDelegate which creates QComboBox editor in createEditor() method. The editor closes only when user chooses an item in the list and the presses Enter key. I want the editor to be closed only when user chooses the item. How to do this?

I've tried to use QComboBox's currentIndexChanged() signal, but it's emitted even when user just clicks the table cell to view the editor.

Alexander_KH
  • 189
  • 12

1 Answers1

4

You need to connect QComboBox::currentIndexChanged signal to a slot in your delegate. Inside the slot you should emit closeEditor signal.

Initial currentIndexChanged signal emission is most likely caused by you setting current index after creation. Just put the connect statement below setting value of the combo box.

Pavel Strakhov
  • 39,123
  • 5
  • 88
  • 127