Search code examples
c++qtqcomboboxqlineedit

How to remove cursor from editable QComboBox when I either press enter or click mouse outside its area?


I have a QComboBox which is made editable. When I type some text in it and press enter, it is performing its action. But the cursor still blinks in the text box. And even if by mistake I press any UP/DOWN key the item is changing.

How to remove this blinking cursor if I press enter or click mouse outside its area?


Solution

  • That is the standard behavior of a combo box, in Qt or in any other toolkit. If you want that cursor to stop blinking, then give the keyboard focus to another widget. You can call QWidget::setFocus() on another widget of your application. Also have a look at the general documentation about focus in Qt5, Keyboard Focus in Widgets, to get more input on keyboard focus.