Frameless window not working with qt 6.8
-
I have an application which has a custom title bar (which is still not supported by Qt btw).
For this I have been using https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window
It implements frameless windows natively in Windows. And it was working well with Qt 5.15 :- Aero snaps working
- Resizing working
- Click and drag the title bar to move the window OK
- Double click title bar to maximize OK
- Shadows drawn correctly
- Overall working perfectly.
And now I upgraded to Qt 6.8.1 and nothing works (aside from moving the window by click and drag).
On the picture below you can see the same app build with Qt5.15 on top and with Qt6.8.1 under.
This is on Windows11, so you can see the one build on 5.15 has a good native support for frameless because you can see the round corners and the correct styling/shadows.Here is the class if someone care to check it out : https://pastebin.com/raw/ThKuiJ26
Note I can't put the code in because of Akismet spam detection!It looks like the part about SetWindowLong and DwmExtendFrameIntoClientArea is not working anymore. Does anyone know anything about it?
-
So it appears that SetWindowLong and/or DwmExtendFrameIntoClientArea are somehow overwriten on Qt 6.8.1 when they are done in the Ctor of the mainwindow.
So I finally found a workaround by adding a QTimer :
QTimer::singleShot(10, this, [this]() { HWND hwnd = (HWND)this->winId(); DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); ::SetWindowLong(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION); const MARGINS shadow = { 1, 1, 1, 1 }; DwmExtendFrameIntoClientArea(HWND(winId()), &shadow); });
This way the code is not overwriten and it works. But it feels quite hacky
-
I have an application which has a custom title bar (which is still not supported by Qt btw).
For this I have been using https://github.com/Bringer-of-Light/Qt-Nice-Frameless-Window
It implements frameless windows natively in Windows. And it was working well with Qt 5.15 :- Aero snaps working
- Resizing working
- Click and drag the title bar to move the window OK
- Double click title bar to maximize OK
- Shadows drawn correctly
- Overall working perfectly.
And now I upgraded to Qt 6.8.1 and nothing works (aside from moving the window by click and drag).
On the picture below you can see the same app build with Qt5.15 on top and with Qt6.8.1 under.
This is on Windows11, so you can see the one build on 5.15 has a good native support for frameless because you can see the round corners and the correct styling/shadows.Here is the class if someone care to check it out : https://pastebin.com/raw/ThKuiJ26
Note I can't put the code in because of Akismet spam detection!It looks like the part about SetWindowLong and DwmExtendFrameIntoClientArea is not working anymore. Does anyone know anything about it?
@Paddle said in Frameless window not working with qt 6.8:
custom title bar (which is still not supported by Qt btw)
The title bar is decorated by the native window manager, so it's not exactly platform independent and probably not a target of a platform-independent framework like Qt.
And now I upgraded to Qt 6.8.1 and nothing works (aside from moving the window by click and drag).
Unless somebody knows better I would say that I could be a/another Windows11 style issue.
Does it also break on 6.8 when using vista style for example?
-
So it appears that SetWindowLong and/or DwmExtendFrameIntoClientArea are somehow overwriten on Qt 6.8.1 when they are done in the Ctor of the mainwindow.
So I finally found a workaround by adding a QTimer :
QTimer::singleShot(10, this, [this]() { HWND hwnd = (HWND)this->winId(); DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); ::SetWindowLong(hwnd, GWL_STYLE, style | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CAPTION); const MARGINS shadow = { 1, 1, 1, 1 }; DwmExtendFrameIntoClientArea(HWND(winId()), &shadow); });
This way the code is not overwriten and it works. But it feels quite hacky