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. QWidget::raise () behaving differently on Windows / MacOS regarding focus
Forum Update on Monday, May 27th 2025

QWidget::raise () behaving differently on Windows / MacOS regarding focus

Scheduled Pinned Locked Moved Unsolved General and Desktop
focuswindowsmacoswidget
3 Posts 2 Posters 178 Views
  • 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.
  • Y Offline
    Y Offline
    yan.nekola
    wrote on last edited by
    #1

    Hello, I have a question regarding a difference in the behaviour of QWidget::raise () between Windows / MacOS. On MacOS, calling the method gives focus to the widget, but on Windows this is not the case.

    It can be tested by periodically calling raise () on a QWidget, and trying to write on a text editor while the Qt application is running. On Windows one is able to continue writing indefinitely, whereas on MacOS focus is taken out of the text editor and given to the QWidget.

    Is this a known / accepted difference of behaviour across the two OS? Is it a bug?

    Thanks in advance.

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

      This behavior difference is expected due to how the operating systems manage window focus:

      • On Windows, calling QWidget::raise() only raises the widget to the top of the stacking order, but does not steal focus from other applications. Windows actively prevents programs from taking focus arbitrarily.
      • On macOS, calling raise() can also cause the widget to receive focus, depending on the application's state and system settings. macOS allows applications to reclaim focus more aggressively.

      In Qt, raise() itself only requests the window manager to raise the widget, focus behavior is handled by the underlying OS.

      If you want consistent behavior across platforms, you'll need to check the widget's focus state and implement additional logic to prevent macOS from stealing focus when raising the widget.

      (macOS always finds a way to introduce crazy behaviors — and somehow make Mac fans love it even more. 😄)

      Hope this helps!

      1 Reply Last reply
      1
      • Y Offline
        Y Offline
        yan.nekola
        wrote on last edited by
        #3

        That makes sense, thank you.

        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