Resize client area for borderless window
-
I remove the Windows default frame using:
@
MARGINS margins = {-1,-1,-1,-1};
DwmExtendFrameIntoClientArea((HWND)winId(), &margins);
setWindowFlags(Qt::FramelessWindowHint | Qt::CustomizeWindowHint /| Qt::WindowSystemMenuHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint/);
@
This works ok. However when I enable the minimize, maximize and close commands Qt seems to add a border internally to its calculations again, although I have specified FramelessWindowHint.
Then all the popup menus are vertically off by the amount of pixels Qt thinks the caption of the window consumes. Also it does no longer completely fill the (still borderless)
window with its client area.
Is there a way to stop Qt from adding the borders to its calculations? -
My uneducated assumption is that you should not use a frameless window and ask for standard buttons. I think there is an example in the documentation regarding this.
Short quotation from memory with no guarantee of delivering the perfect solution: If you remove the frame, you should implement your own buttons to minimize, maximize and close the window. You can position these buttons however you want, and query QStyle::standardIcon (maybe there is a better way) to receive some recogniable icons for these buttons.
What you are describing sounds like a bug in Qt, by the way. Did I misinterpret your words?
-
thanks for your reply. Adding the button hints should not modify the internal rect Qt thinks the Window has, if it is still frameless. Because the hints are primarily used to have the minimize/maximize/close functionality in the programs system menu (and the keyboard shortcuts).
So it does seem to be a bug then.