以下是整理的4中設置透明窗體的方法
(1) Qt::WA_NoSystemBackground, Qt::WA_TranslucentBackground:
setAutoFillBackground(false); //這個不設置的話就背景變黑
setWindowFlags(Qt::FramelessWindowHint);
setAttribute(Qt::WA_TranslucentBackground,true);
(2) setWindowOpacity(1); //0是全透明,1是不透明 窗口及其上面的控件都半透明:
(3) setStyleSheet("background-color:transparent;"); 樣式表設置透明
(4) QPalette pal = palette();
pal.setColor(QPalette::Background, QColor(0x00,0xff,0x00,0x00));
setPalette(pal); 窗口整體透明,但窗口控件不透明,QLabel控件只是字顯示,控件背景色透明;
窗體客戶區完全透明