Borderless window in Qt on Windows which supports native features: aero snap, DWM resize and minimization
Asked Answered
F

2

10

I'm trying to create a borderless window in Qt on Windows which supports native features: aero snap, DWM resize and minimization, shake, etc. Like Office 2013 or Visual Studio 2012. But they are written in wpf. There are a lot of examples in wpf and pure WinApi, but I wasn't able to find any Qt example.

Recently I've found Blizzard's Battle.net App(screenshot). They are using QT 4.8.5 and their main window looks and behaves exactly as I want in my app.

Does anyone know how to do that?

Thanks for your help.

Findley answered 3/3, 2014 at 22:2 Comment(3)
Though I'm not sure about the aero snap you can implement this by using QWidget::setWindowFlags() which will allow you to draw these controls yourself (which is probably what the battle.net app is doing seeing as it has pretty much custom menu controls). There is a really nice article on this: qt.developpez.com/tutoriels/braindeadbzh/customwindow - Downside is that it is in French.Deuced
My application works like that now. Aero snap doesn't work. When minimized, window disappears without any animation.Findley
I am looking for the same behaviour. Have you found a solution? Thanks in advance.Willy
F
7

I've found a workaround for this problem.

Instead of using Qt main window, i've created a simple WinAPI borderless window, like in this SO discussion. Then i added QWinWidget from QtWinMigrate project, and filled window with it.

As result, main window and resizable edges are handled by WinAPI, and everything inside main window is handled by QWinWidget. And with QWinWidget you can create Qt gui like in any other Qt app.

Here is a small example project on GitHub.

Findley answered 2/8, 2014 at 22:14 Comment(2)
I need to replace a QMainWindow subclass with your BorderlessWindow class. What do you think is the best approach?Bullnose
My class is not a subclass of QT object. You probably should replace QMainWindow subclass with QWinWidget subclass.Findley
A
1

Perhaps this might help you, Windows specific Qt classes WinExtras

http://qt-project.org/doc/qt-5/qtwin.html

http://qt-project.org/doc/qt-5/qtwinextras-module.html

Besides you can use QT Quick 2.0 to design UI similar to WPF

Africander answered 4/3, 2014 at 6:54 Comment(5)
Following your advice, I've tried this classes. This example shows what you can achieve with them. Looks interesting, but still not what i need.Findley
@Findley winextras is only for aero, for customized window and effetc you can use QT Quick 2.0, see the "Example and Demo" binary of Qt, when you install Qt, you can find that in Start Menu -> QtAfricander
I don't have any problems with customizing ui. I'm talking about main window.Findley
@Findley you can have a borderless window and then customize it https://mcmap.net/q/742874/-modern-looking-ui-with-qtAfricander
And this window won't be native. No aero snap and other dwm features.Findley

© 2022 - 2024 — McMap. All rights reserved.