Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to setFocus on two widgets at once
lantern last edited by
I need to have a widget exactly like Sublime Text menus, like the package control / theme menu.
The QLineEdit can always be typed in and the list can always be scrolled as long as their parent widget is active. Is this possible in Qt?
well if u set list to Nofocus you can scroll it with mouse and keyboard focus stays with
lantern last edited by lantern
Well its not ideal but I got it working.
- ListView has noFocus policy.
- If line edit has focus, re-implemented up and down arrows keys change index and selection of listview.
- Line Edit change policy to clickFocus because otherwise the arrows keys cause it to get focus (undesirable).
- connect ListView row clicked to accept and close events even if the menu wasnt focused.
- Style listview selected:!active so it doesnt show two different colors on click
I will post the code soon, I also want to try the classical QListWidget, it might be way simpler and should be faster?