I finally figured out how to do this. I did it by capturing the Qt::FocusIn event on the delegate's eventFilter() function. There I used the pointer to the editor to call the deselect() function.