Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Grab focus in a multi window QApplication
Qt 6.11 is out! See what's new in the release blog

Grab focus in a multi window QApplication

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anna234
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • RichardR Offline
      RichardR Offline
      Richard
      wrote on last edited by
      #2

      What is the focus policy set to of the widgets, chance is that this is set to no focus, try setting it on strongfocus.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved