QtWidgets: Is it possible to apply flat main window style (Visual Studio-like) via QSS?
-
Custom look is no big deal. As you said yourself a frameless window with a couple of mouse events can do the trick.
The real problem, as I mentioned earlier, is the true native behavior on given platform, which is often non-trivial.Notice that at least Origin client has exactly the half-baked solution I talked about - completely ignores OS integration, i.e. Aero features like snap or Win + arrows shortcuts don't work and maximizing on multiple screens has issues too. It also renders frame as part of taskbar thumbnail, which apps shouldn't do. As a result it doesn't feel native at all.
Some of the issues can be avoided with a fixed size window (I think the Blizard thingie does that?), but it doesn't fit with all apps .I've actually seen many many apps doing it wrong one way or another and really a handful doing it right.
Even Visual Studio has issues - when it becomes heavy loaded a micro-freezes occur at which time the OS tries to handle it by drawing native frame over the frozen app, which looks terrible.Not to say it's impossible. It's just really really hard to nail all the details and I guess nobody (to my knowledge) cared enough to perfect it and release for free.
I have personally tackled it many times and have a couple of "almost always working" solutions. They are just so hacky and ugly (code wise) I wouldn't feel comfortable sharing them with others. I guess others that did this feel similarly, although if you look through this forum you'll find code of such failed, or not entirely working attempts. -
I bet if it was on Github and received some advertisement, we (the community) would more or less polish it.
Good catch on the Origin client failures. Battle.net, of course, also draws the whole window in the thumbnail, but it does support snap to screen edges (incl. Win + arrows). WinAPI code?.. -
This looks decent: https://github.com/deimos1877/BorderlessWindow
The code, though... quite complicated, and Windows-only. -
This looks decent
Sorta does the job but I don't really like it. Seems heavy and intrusive - two event loops, stylesheets, images, resources and external library needed.
Also the API needs a lot of polishing to be more in line with Qt - for example why would a widget take application pointer and store it? I also really dislike that the header bleeds "windows.h" into the app and the main class exposes native types (e.g. styles, HBRUSH, HWND, WPARAM etc.) to the user. This needs to be hidden away behind an API that has Windows specific stuff ifdeffed.But thumbs up for the effort. It might be a starting point, though I'm not convinced about the method. I'd personally go for handling native events inside the widget instead of embedding it in native window via QWinWidget. I'd like my main window to be a QWidget too.
Btw. It's an uphill battle. In about two weeks Windows 10 comes out and with sandboxed WindowsRuntime apps that can be now windowed this doesn't even cover one platform entirely, let alone linux, macos or others.
-
Well, personally, I'm not interested in WinRT, only the good old x86 Win NT. I don't have a single WinRT-compatible application.
-
I'm not talking about WinRT - the "tablet OS". I'm talking about the Windows Runtime - the successor of WinAPI (great job at not confusing users with ambiguous names Microsoft :P). The stuff that used to be called "metro apps". It's pushing to be the prevailing API for writing windows apps, especially since they are back to windows in Windows 10 instead of being fullscreen in Windows 8. If you're not interested in that now, you will be (or will have to be) in at most couple of months/years.
-
Got it. But I doubt good old WinAPI / WPF applications will stop working any time soon.
-
@Chris-Kawa I just have to say this is hilarious and spot on. I did this same thing in wxWidgets a couple years ago and this was my experience verbatim. In the end I went on to use the same basic technique that is described here: https://github.com/deimos1877/BorderlessWindow. Thanks for making me feel less stupid.
-
@Violet-Giraffe (and others). I know many people are looking for this, so I still reply on this old topic. You might want to take a look at this project:
https://github.com/stdware/qwindowkitThis is on Windows 11:
-
@niquedegraaff, thank you, that's very cool! I have not heard of that project.