PDA

View Full Version : How to know if a window is on top ?



Lele
18th June 2007, 18:26
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?

Lele
18th June 2007, 18:40
sorry, stupid question, IsActiveWindow could work.
bye

Eldritch
18th June 2007, 19:39
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.

wysota
18th June 2007, 20:20
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.

Lele
29th June 2007, 16:14
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

jpn
29th June 2007, 21:58
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() ?

Lele
2nd July 2007, 14:52
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

Eldritch
2nd July 2007, 22:15
To do this, you can try QWidget::raise() as jpn suggested, but it may not work. You can look here (http://msdn2.microsoft.com/en-us/library/ms633539.aspx) 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.

ber_44
3rd July 2007, 05:32
"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 (http://www.qtcentre.org/forum/f-qt-programming-2/t-on-there-is-no-reliable-way-to-activate-a-window-7427.html))

SetForegroundWindow (http://msdn2.microsoft.com/en-us/library/ms633539.aspx) seems like a mess on different Windows versions.

On Macintosh, this problem does not exist.