Qt5增加了许多特性,其中 Qt Windows Extras 模块就增加了对Win7 Aero 效果的支持。
官网的介绍如下:
In addition, you can use features introduced with Windows 7, such as Aero Peek, Jump Lists, a progress indicator on a taskbar button, or a thumbnail toolbar.
步骤(1):在Qt工程中添加模块:winextras
步骤(2):包含头文件:<QtWin>
源代码(从Qt5示例中截取来的):
- if (QtWin::isCompositionEnabled()) //返回DWM组合状态
- {
- QtWin::extendFrameIntoClientArea(this, -1, -1, -1, -1); //玻璃效果
- setAttribute(Qt::WA_TranslucentBackground, true); //半透明背景
- setAttribute(Qt::WA_NoSystemBackground, false); //禁用无背景
- setStyleSheet("MusicPlayer { background: transparent; }");
- }
- else
- {
- QtWin::resetExtendedFrame(this);
- setAttribute(Qt::WA_TranslucentBackground, false);
- setStyleSheet(QString("MusicPlayer { background: %1; }").arg(QtWin::realColorizationColor().name()));
- }
看效果:
参考:
http://qt-project.org/doc/qt-5/qtwinextras-index.html qtwinextras索引
http://qt-project.org/doc/qt-5/qtwinextras-overview.html qtwinextras概述
http://qt-project.org/doc/qt-5/qtwin.html QtWin API