[Interest] Gluing windows to the bottom

Bob Hood bhood2 at comcast.net
Mon Dec 5 18:44:36 CET 2016


Ok, here's another one for the brain trust...

I'm creating windows in a tasktray application (Windows 7 64-bit).  These 
"child" windows inherit from QWidget and are not parented, but they are being 
created by the main application.

I can "glue" them to the screen (i.e., top of Z order) using the 
Qt::WindowStaysOnTopHint flag, and that works perfectly.  However, I want to 
"glue" them to the desktop instead (i.e., bottom of Z order), and using 
Qt::WindowStaysOnBottomHint doesn't appear to accomplish that with the same 
persistence as Qt::WindowStaysOnTopHint, at least under Windows.

I understand this may require a platform-specific solution, and I can accept 
that since this tool will probably only be used under Windows.  I even tried 
using SetWindowPos() directly after opening the window:

     void Headline::showEvent(QShowEvent *event)
     {
         QWidget::showEvent(event);
         SetWindowPos((HWND)winId(), HWND_BOTTOM, 0, 0, 0, 0, 
SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
     }

But that doesn't seem to maintain the order.  I'm also using 
Qt::WA_ShowWithoutActivating, and that seems to work, but once I move the 
window (using QPropertyAnimation, for example), activation and Z-order 
shifting become an issue.I guess my question becomes: Is there a way to force 
a window to the background behind all other windows, and /keep/it there even 
if it is being interacted with--programmatically or, for example, by the user 
clicking on it?  Something tells me that intercepting and ignoring events 
might do it, but I'm not sure if that's the right approach.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20161205/42624c35/attachment.html>


More information about the Interest mailing list