简体   繁体   English

Windows上Qt中的无边框窗口,支持本机功能:aero snap,DWM调整大小和最小化

[英]Borderless window in Qt on Windows which supports native features: aero snap, DWM resize and minimization

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. 我正在尝试在Windows上的Qt中创建一个无边框窗口,它支持本机功能:aero snap,DWM调整大小和最小化,抖动等。例如Office 2013或Visual Studio 2012.但它们是用wpf编写的。 There are a lot of examples in wpf and pure WinApi, but I wasn't able to find any Qt example. 在wpf和纯WinApi中有很多例子,但是我找不到任何Qt例子。

Recently I've found Blizzard's Battle.net App( screenshot ). 最近我发现了暴雪的Battle.net App( 截图 )。 They are using QT 4.8.5 and their main window looks and behaves exactly as I want in my app. 他们正在使用QT 4.8.5,他们的主窗口在我的应用程序中看起来和行为完全符合我的要求。

Does anyone know how to do that? 有谁知道这是怎么做到的吗?

Thanks for your help. 谢谢你的帮助。

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 . 我没有使用Qt主窗口,而是创建了一个简单的WinAPI无边框窗口,就像在这个SO讨论中一样 Then i added QWinWidget from QtWinMigrate project, and filled window with it. 然后我从QtWinMigrate项目中添加了QWinWidget,并用它填充了窗口。

As result, main window and resizable edges are handled by WinAPI, and everything inside main window is handled by QWinWidget. 因此,主窗口和可调整大小的边缘由WinAPI处理,主窗口内的所有内容都由QWinWidget处理。 And with QWinWidget you can create Qt gui like in any other Qt app. 使用QWinWidget,您可以在任何其他Qt应用程序中创建Qt gui。

Here is a small example project on GitHub. 这是GitHub上的一个小示例项目。

Perhaps this might help you, Windows specific Qt classes WinExtras 也许这可能对你有帮助,Windows特定的Qt类WinExtras

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

http://qt-project.org/doc/qt-5/qtwinextras-module.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 此外,您可以使用QT Quick 2.0设计类似于WPF的UI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM