[Interest] Creating a custom window issues

Murphy, Sean smurphy at walbro.com
Mon Aug 19 20:27:43 CEST 2019

I'm having a bit of an issue creating a custom window with the 
following requirements:
1. Customized window control buttons
  a. I want to keep the 'X' button to close the window,but I do not 
      want the minimize or maximize buttons shown
  b. In addition, I then need to add my own custom button(s)
2. The window should retain the normal window shadow effect

Two satisfy requirement #1a, I first tried:
  setWindowFlags(Qt::CustomizeWindowHint |

That seems to get rid of the minimize & maximumize buttons, 
but I don't see any way to then add my own customized button 
to the left of the close ('x') button. Please correct me if I'm wrong 
on that count, since if there's a way to add custom buttons to 
that bar, I'd probably be all set, and everything I'm about to say 
below goes away.

Assuming there isn't a way of adding a custom button, I then 
went down a path of using:
 - setWindowFlags(Qt::FramelessWindowHint | Qt::CustomizeWindowHint);
 - create my own fake title bar widget and adding my own 
   custom buttons that, one of which looks like the standard close button 
The issue with this is that by setting Qt::FramelessWindowHint, the 
window shadow disappears.

So then I tried removing the Qt::FramelessWindowHint flag. 
This brings back the window shadow, but it also adds a small white band 
above my button bar widget.

You can see what I'm talking about here: 
https://imagebin.ca/v/4s4QprMkIsvD. The left side of that image 
shows what my window looks like with the Qt::FramelessWindowHint 
enabled. It shows there is no drop shadow (which is bad), but  also 
no excess whitespace above my fake title bar (which is good). The right 
side of the image shows the result without setting the Qt::FramelessWindowHint
flag. In that instance, the drop shadow is present (good), but I've suddenly got
excess whitespace above my fake title bar (bad). It appears the 
whitespace is about 6 pixels high.

What I want is a combination of both - no excessive whitespace, 
but with the drop shadow. Is there some way to get rid of that 
excess whitespace?


This message has been scanned for malware by Forcepoint. www.forcepoint.com

More information about the Interest mailing list