Important: Please read the Qt Code of Conduct -

Highlight/focus first action in QMenu on show

  • I'm having a QMenu show up with suggestions while entering text. The suggestions are arranged by probability, and usually the first suggestion is correct. This works well except the user has to click enter twice to select the item, once to first get highlighted the first item, then another time to select. Same goes for tabbing to an option. This is inefficient and unnecessary clicks for the user. Initial user testing also shows that users think it is not responding properly.

    How can i give focus or highlight to the first action in a QMenu after calling popup? So that the first item is selected with a single click on enter, and the second is highlighted with a single click on the tab button?

  • Lifetime Qt Champion


    AFAIK, you can't do that because it's not how menu works. Wouldn't you be best served with a popup like the one QCompleter provides ?

  • @SGaist that's exactly what I need! Didn't know that existed, how incredibly convenient. Thank you!

Log in to reply