Results 1 to 9 of 9

Thread: How to know if a window is on top ?

  1. #1
    Join Date
    Jan 2006
    Posts
    122
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    16

    Default How to know if a window is on top ?

    Hi,
    Is there a way to know if a window is on top of all the others?
    I don't meant to set the flag Qt::WindowStaysOnTopHint but just to know if the window is on top of all the others?

  2. #2
    Join Date
    Jan 2006
    Posts
    122
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    16

    Default Re: How to know if a window is on top ?

    sorry, stupid question, IsActiveWindow could work.
    bye

  3. #3
    Join Date
    Aug 2006
    Posts
    44
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 7 Times in 7 Posts

    Default Re: How to know if a window is on top ?

    Actually, this is not a stupid question at all. Say you *do* have some windows that are always on top, and some that are not. The question of where a window is in Z-plane (stacking) order is different from whether the window is active (where user input is going) or not.

    Now, if you were looking for the active window, then you did answer your own question. If you're talking about which windows are above / below in stacking order... I've found Qt lacking in providing that information, and have resulted to OS-specific mechanisms in most cases.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to know if a window is on top ?

    Furthermore some window managers don't raise active windows, so even if you don't have any windows with a "stays on top" hint, it doesn't yet mean the active window is the one on top.

  5. #5
    Join Date
    Jan 2006
    Posts
    122
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    16

    Default Re: How to know if a window is on top ?

    Thanks for answering, so what do you suggest to do if I want to raise the window of my QT app when it's under some other dialogs?
    I'm using Windows XP
    bye

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: How to know if a window is on top ?

    Quote Originally Posted by Lele View Post
    o what do you suggest to do if I want to raise the window of my QT app when it's under some other dialogs?
    QWidget::raise() ?
    J-P Nurmi

  7. #7
    Join Date
    Jan 2006
    Posts
    122
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    16

    Default Re: How to know if a window is on top ?

    thanks, I meant when other dialogs are not in my app but regular dialogs from other softwares. Is there a put on top (like hint Qt::WindowStaysOnTopHint) but then after putting it on top return to a "normal" state where others can then overlap?

    thanks
    bye

  8. #8
    Join Date
    Aug 2006
    Posts
    44
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 7 Times in 7 Posts

    Default Re: How to know if a window is on top ?

    To do this, you can try QWidget::raise() as jpn suggested, but it may not work. You can look here for some information about how this used to work. There are ways to accomplish what you want that are Windows-specific code. Searching MSDN for SetForegroundWindow will get you some of what you need. With a solid understanding of how Windows input processing works, you can find other ways to subvert what the OS is doing to prevent apps from jumping in front of each other, too.

    Hope this helps.

  9. #9
    Join Date
    Apr 2007
    Posts
    46
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    4

    Default Re: How to know if a window is on top ?

    "I've found Qt lacking in providing that information, and have resulted to OS-specific mechanisms in most cases."
    - Eldritch

    I really would like to see a working example for this problem (I also asked it in this thread)

    SetForegroundWindow seems like a mess on different Windows versions.

    On Macintosh, this problem does not exist.

Similar Threads

  1. Replies: 4
    Last Post: 4th June 2007, 13:07
  2. Regarding drawing on Transparent Window
    By Shalabh in forum Qt Programming
    Replies: 3
    Last Post: 31st May 2007, 11:32
  3. Window not responding
    By markcole in forum Qt Programming
    Replies: 10
    Last Post: 18th April 2007, 22:53
  4. move parent window to the front.
    By hvengel in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2007, 09:41
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 11:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.