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 bring to front on Windows?
Forum Updated to NodeBB v4.3 + New Features

How bring to front on Windows?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 5.6k Views 2 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
    AndrzejB
    wrote on last edited by
    #1

    I use :

        show(); //bring window to top on OSX
        raise(); //bring window from minimized state on OSX
        activateWindow(); //bring window to front/unminimize on windows
    

    but this is not enough - in Windows 10 only flicks application on system status bar. It is not possible on Windows 10?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Well in windows 10, there are rules.
      https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setforegroundwindow
      see the Remarks section
      so what you see might be this
      "An application cannot force a window to the foreground while the user is working with another window. Instead, Windows flashes the taskbar button of the window to notify the user."

      1 Reply Last reply
      2
      • Chris KawaC Online
        Chris KawaC Online
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        This is the default behavior on Windows and you should think twice before overriding it. It's extremely annoying when apps steal focus, especially if you're typing or have another full screen app opened at that time.

        That being said you can change this behavior for your app by calling

        #ifdef Q_OS_WIN //this is Windows specific code, not portable
            QWindowsWindowFunctions::setWindowActivationBehavior(QWindowsWindowFunctions::AlwaysActivateWindow);
        #endif
        

        this will cause activateWindow() to bring your app to front. You should put that in a platform ifdef, as this is Windows specific switch.

        I'll repeat that this is strictly against platform recommendations and you should not do that unless you have a very good reason and I have yet to see an app that really does.

        1 Reply Last reply
        4
        • A Offline
          A Offline
          AndrzejB
          wrote on last edited by
          #4

          This is annoing in most cases, but I am writing editor which has many tabs and one instance and should be called from TotalCommander/DoubleCommander etc.

          1 Reply Last reply
          0
          • Chris KawaC Online
            Chris KawaC Online
            Chris Kawa
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @AndrzejB That sounds like even more reasons not to do it. An app should never assume how it is invoked - through explorer, another process, command line, service etc. It should be the caller (user, app, service or whatever) responsibility to activate the process it started, not the process itself.

            1 Reply Last reply
            3

            • Login

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