How to close QComboBox editor in delegate when user selects item
I have a QStyledDelegate that creates a QComboBox editor in the createEditor () method. The editor closes only when the user selects an item in the list and presses the Enter key. I want the editor to close only when the user selects an item. How to do it?
I tried to use QComboBox currentIndexChanged () but it was emitted even when the user just clicks on a table cell to view the editor.
source to share
You need to connect the signal QComboBox::currentIndexChanged
to a slot in your device. Inside the slot, you must emit a signal closeEditor
.
The original signal emission is currentIndexChanged
most likely caused by setting the current index after creation. Just put the connect statement below the value for the combo box.
source to share