以下是实现areo效果的类,以及使用方法:
************************main.cpp******************************
#include <QtGui>
#include "aero.h"
int main(int argc,char*argv[])
{
QApplication app(argc,argv);
QMainWindow w;w.resize(900,900);
//***********************************************
#ifdef Q_WS_X11
window.setAttribute(Qt::WA_TranslucentBackground);
window.setAttribute(Qt::WA_NoSystemBackground, false);
QPalette pal = window.palette();
QColor bg = pal.window().color();
bg.setAlpha(180);
pal.setColor(QPalette::Window, bg);
window.setPalette(pal);
window.ensurePolished(); // workaround Oxygen filling the background
window.setAttribute(Qt::WA_StyledBackground, false);
#endif
if (QtWin::isCompositionEnabled()) {
QtWin::extendFrameIntoClientArea(&w);
w.setContentsMargins(0, 0, 0, 0);
}
//*********************************************************
w.show();
return app.exec();
}
*******************aero.h************************
aero.h
#ifndef AERO_H
#define AERO_H
#include <QColor>
#include <QWidget>
class WindowNotifier;
class QtWin
{
public:
static bool enableAeroWindow(QWidget *widget, bool enable = true);
static bool extendFrameIntoClientArea(QWidget *widget,