一、效果圖
1、主界面
2、子界面
二、代碼
//①設置界面基本顏色
this->setAutoFillBackground(true);//屬性控制小部件背景是否自動填充
QPalette palette = this->palette();
palette.setColor(QPalette::Base,QColor(0,0,0,255));//alpha 0~255;0為不透明,255為透明
palette.setColor(QPalette::Window,QColor(0,0,0,100));//alpha 0~255;0為不透明,255為透明
this->setPalette(palette);
//這樣設置就可以了,但是我的需求是窗體要有邊框,故需要添加下邊一步
//②使用樣式變添加邊框,設置透明背景
ui->tableWidget->setStyleSheet(QString("border-width: 2px;"\ "border-style: solid;"\ "border-radius:15px;"\ "border-color: rgb(255,255,255);"\ "background-color:transparent;"));