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. [solved] Raise Window to Front using "SwitchToThisWindow"

[solved] Raise Window to Front using "SwitchToThisWindow"

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

    Hi guys and girls,

    I want the MainWindow to be pushed on top of the windows stack.
    As I understand an application shall not do this, that's why raise() and showNormal() won't do.

    My plan is to use the windows routine SwitchToThisWindow( HWND hWnd, BOOL fAltTab )
    http://msdn.microsoft.com/de-de/library/windows/desktop/ms633553(v=vs.85).aspx

    What kills my plan is that the windows handle seems not to be accessible any longer in 5.x.
    I tried the way around via

    QPlatformNativeInterface* interfacep = QGuiApplication::platformNativeInterface();
    HWND handle = static_cast<HWND>(interfacep->nativeResourceForWindow(QByteArrayLiteral("handle"), window() ));
    SwitchToThisWindow( handle, (WINBOOL)false );

    But the window handle seems to be wrong, because some windows will be raised, but not the correct one (it is the same during one run each time the SwitchToThisWindow() is called, but when the program is restarted, it is randomly any window).

    Question A) is there maybe only a problem with the cast and the routine to get the window handle is wrong?

    Question B) is there a solution provided by the QT-API to switch the window to the top, so I can drop the windows specific SwitchToWindow() routine?

    Thanks so far...

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mc7ack
      wrote on last edited by
      #2

      ...sorry, was my fault...
      The windows handles are correct. When I set the bool "by alt-tab" to true, the correct window reacts.
      But that way the application blinks and comes not to the front. That's the same like showNormal(), so I didn't win anything...

      If anybody has an idea how to raise a window above all other windows I would appreciate it, but the initial question as I described it seems to be solved.

      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