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. How can I check if my application's Window is currently in 'focus'?
Forum Updated to NodeBB v4.3 + New Features

How can I check if my application's Window is currently in 'focus'?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.8k 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.
  • K Offline
    K Offline
    katanaswordfish
    wrote on last edited by
    #1

    I have a QGuiApplication with a single top-level window which is able to be controlled using game controller inputs. It's working fine, but I've been having an issue where my application is accepting/processing controller inputs while a different application is 'in focus'. To avoid this, I want to wrap my processEvents() in a conditional statement that first checks if the applications main window is currently in focus; if it isn't the currently 'active' or 'focused' window, both the keyboard and gamepad events will be ignored.

    So, whats the best way to check if your applications window is 'in focus'?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      katanaswordfish
      wrote on last edited by
      #2

      Actually, nevermind. After combing through the QGuiApplication class documentation a second time I found what I was looking for.

      QGuiApplication::focusWindow() [static]

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hareen Laks
        wrote on last edited by
        #3

        As I understand your question you need "hasFocus()":http://qt-project.org/doc/qt-4.8/qwidget.html#focus-prop. isn't it?

        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