⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)
Grab focus in a multi window QApplication
Anna234 last edited by
Hi, I have a QApplication with multiple windows. On some of the windows, I have QWidgets grabbing the keyboard. On one window I have a complex application with many QWidgets. Now I'd like those QWidgets (text fields, scroll areas, and so on) to grab the keyboard whenever the mouse is clicked on them, so that the user can type in text. This works automatically with just a single window, but with multiple windows, it does not work. The keyboard is not grabbed, and if it is grabbed and someone types something in a text field, the text field looses focus immediately when typing starts. Text is written into it, but there is not blinking cursor.
What is the right approach to grab focus for particular (or all) QWidgets on a window, if I run a multi window QApplication.
Richard last edited by
What is the focus policy set to of the widgets, chance is that this is set to no focus, try setting it on strongfocus.