设置属性
this->setAttribute(Qt::WA_TranslucentBackground, true);
重写绘制函数
void ThreeSplitScreenPlaybackHoverToolBarWidget::paintEvent(QPaintEvent*event)
{
QPainter p(this);
p.setPen(QColor(0, 0, 0, 150));
p.setBrush(QColor(0, 0, 0, 150));
//p.setCompositionMode(QPainter::CompositionMode_Clear);
//p.fillRect(10, 10, 300, 300, Qt::SolidPattern);
p.drawRect(this->rect());
QWidget::paintEvent(event);
}