I can't achieve the aero effect of windows7 using dwm on windows10
-
I want to achieve the effect shown below
But I got this effect using the following code
QtWin::extendFrameIntoClientArea(this,-1,-1,-1,-1); setAttribute(Qt::WA_TranslucentBackground,true); setAttribute(Qt::WA_NoSystemBackground,false); setStyleSheet(QStringLiteral("MainWindow { background: transparent;}"));
Is there any way to achieve the glass effect I want?
thank you ! -
There's gonna be a couple roadblocks ahead of you.
First - there's no Aero in Windows 10 or above. DWM on 10 and 11 uses a different, opaque material by default.
You can customize the backdrop material, but it's not gonna be easy. The closest to Aero that Windows 10 provides out of the box is Mica (a material with a frosted glass effect over windows desktop) and Acrylic (a material with a frosted glass effect that also blurs all windows below it).Unfortunately Microsoft originally provided them only as XAML materials for UWP apps. After tons and tons of complaints from users and a couple years later they made their way into the Windows AppSDK and WINUI3, which are C#, C++/CX or C++/WinRT libraries for Windows 11 app development. See here for details. Due to their massive massive intrusiveness this is not a feasible route for Qt apps I would say.
After even more complaints and even more years later they were finally exposed to Win32 apps (which is what a Qt app on Windows is at its core). It's still not a straightforward process and requires a compositor and still intrusive (although not so much as above) modifications to the basic Window setup. See here for details.
A final two hurdles to overcome are that Qt6 dropped the QtWin extras module, so no DWM interaction is provided by Qt anymore. Also the
Qt::WA_TranslucentBackground
flag in Qt 6 requires you to make the window frameless for some reason. There's no such requirement in WinAPI, and it did work in Qt5, so I consider this a documented regression and very annoying. If you set it on a normal window you will get a black opaque background with no alpha channel that doesn't compose with the Mica or Acrylic material underneath.All very very frustrating developments. I've been watching this space since Aero days and honestly with each new windows SDK and Windows AppSDK release it's a mess after mess. You can't even get a simple Dark/Light value from that garbage for the current system theme. So in summary - it's probably possible if you stick to Qt5, and are ready to make some very platform dependent modifications to the core window setup with a bunch of
winId()
hacking, but it's a road of hurt.