包含头文件:<QtWin>
- 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()));
- }